No, because you're still casting a double to float (if T==float) further up. This is what the spec says about that:

```
If the value being converted is in the range of values that can be represented but cannot be
represented exactly, the result is either the nearest higher or nearest lower representable
value, chosen in an implementation-defined manner. If the value being converted is outside
the range of values that can be represented, the behavior is undefined.
```

So there's room for undefined behavior here. However, all the compilers / architectures we care about do the sensible thing and truncate the value.

You could check that `tmp >= FLT_MIN && tmp <= FLT_MAX && tmp >= -FLT_MAX` (off the top of my head, see float.h for details) if T==float. While that's the correct thing to do, I confess that I personally probably wouldn't bother.