cast float * to unsigned long *
Susukita Ryutaro
susukita@postman.riken.go.jp
Wed Oct 16 23:36:00 GMT 2002
I compiled the following code cast.c with gcc 3.2 on Redhat 8.0 / i386.
#include <stdio.h>
int main(){
float h = 0;
printf("%lx\n", *(unsigned long *)&h);
printf("%lx\n", *(unsigned long *)&h);
}
But the output is different between optimization options.
$ gcc -O cast.c
$ ./a.out
0
0
$ gcc -O2 cast.c
$ ./a.out
4212a2d0
0
Is this a bug or a behavior allowed by ANSI?
SUSUKITA, Ryutaro
The Institute of Physical and Chemical Research (RIKEN)
Computational Science Division
More information about the Gcc-bugs
mailing list