User account creation filtered due to spam.
gcc generates incorrect code from the sample program on several
recent GNU+Linux distributions running on PowerPC. The variable 'unu' is
assigned an incorrect value.
alexcher@ppc64 ~ $ uname -a
Linux ppc64 2.6.21-hardened-r3 #5 SMP Wed Jul 18 17:02:05 UTC 2007 ppc64 PPC970FX, altivec supported PowerMac7,3 GNU/Linux
alexcher@ppc64 ~ $ gcc --version
gcc (GCC) 4.1.2 (Gentoo 4.1.2)
Apparently, gcc doesn't like double casts after optimizing lnum out.
gcc -O2 foo.c
This problem was found on gcc 4.2.1 on PowerPC with -O2 option.
void foo(const char * p, float *pfnum)
lnum = *(int *)p;
*pfnum = *(float *)&lnum;
float one = 1.;
float unu = 2.;
foo( (char *)&one, &unu);
printf("one=%f, unu=%f\n", one, unu);
Both places where you are deferencing is an aliasing violation.
*** This bug has been marked as a duplicate of 21920 ***