I take it that you are a long-time C programmer who hasn't realized that the language is no longer the one you grew up loving. That casting a float to an int to do some bit twiddling is now undefined behavior of the sort that technically entitles the compiler have it's way with your root filesystem. Although usually it will just let you off with a warning and a gaping hole where your null checking code used to be.

Believe it or not, memcpy() is now the only portable and properly defined way to cast one type to another in C. You are expected to use it with the explicit intent that no bytes actually be copied, simply as a (completely voluntary) offering to the type gods. If they accept your offering, the call will just disappear from your code, and never be made. If you fail to make this offering, they feel entitled to excise an equal quantity of other code to punish you.

Sure, you the programmer happen to know that bits are bits, and that on your system they are already in the register you want to use, but the compiler stopped playing that game years ago. If you wanted to work close to the metal, you should have chosen a language more appropriate for the task. There's a great discussion of the issues in this epic comp.arch thread: http://compgroups.net/comp.arch/if-it-were-easy/2993157

Search for the first occurence of 'memcpy', where you'll find a polite but beleaguered Terje Mathisen asking for the best way to portably cast a float to an integer in C. Then keep searching forward for further occurrences of memcpy as the situation becomes surreal, with a GCC maintainer Mike Stump eventually clearing things up:

>>> So what is the blessed method?
>>
>> Just memcpy it, simple sweet, fast, standard.
>
>So what you are saying is that memcpy() isn't just magic but high magic:

No. What I think I'm saying is that it is standard. See the quoted
text above. The word magic [ checking ] doesn't not occur in c99-tc3.
What is defined in that standard is memcpy, it is as standard as if,
which is also defined.

>It looks like a function call but can be whatever the compiler wants it
>to be, as long as the results behave as if the data was actually copied.
>:-)

No, you fail to grasp the totality of the standard. The implementation
is free to do _anything_ it wants. The only constraint is that the user
can't figure that it deviated from the required semantics by using a standards
defined mechanism for figuring it out. We call this the as-if rule, and its
power is awesome; we could destroy the universe, and repiece it back together
one subatomic particle at a time over a billion years, and still be compliant,
if we wanted.

So there you have it: if you want to reuse the exact contents of a register as a different type in a way that you know will work, the correct approach is to use memcpy() to copy the data from one variable to another, and then hope without confirmation that GCC has optimized out the call to make it equivalent to a simple cast.

If you want a better understanding of the GCC mindest, the rest of Mike's posts are excellent: cutting, extremely techically accurate, and (in my opinion) completely missing the point of why some people are unhappy with the direction that C is evolving.