Comment Comment by ChrisFoster Punning through the union is explicitly allowed in the GCC documentation which explains why it's reliable for use in the Linux kernel. Seehttps://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Typ...> you also have to assume the size of those primitive typesThis usually works though there's some situations where you could still be surprised. For instance if you're programming embedded processors with avr-gcc you'll have sizeof(double)==4 parent ChrisFoster 6 years ago
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Typ...
> you also have to assume the size of those primitive types
This usually works though there's some situations where you could still be surprised. For instance if you're programming embedded processors with avr-gcc you'll have sizeof(double)==4