This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
cast float * to unsigned long *
- From: Susukita Ryutaro <susukita at postman dot riken dot go dot jp>
- To: gcc-bugs at gcc dot gnu dot org
- Cc: susukita at postman dot riken dot go dot jp
- Date: Thu, 17 Oct 2002 15:36:22 +0900
- Subject: cast float * to unsigned long *
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