This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
varargs, 64-bit targets, and strict-aliasing warnings
- From: Roland Dreier <roland at topspin dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 26 Aug 2004 16:45:46 -0700
- Subject: varargs, 64-bit targets, and strict-aliasing warnings
Can anyone explain some odd behavior seen compiling this code:
#include <stdint.h>
int foo(int a, ...);
int bar(void)
{
uint64_t x;
return foo(1, (unsigned long long *) &x);
}
If I compile for a 64-bit target with "-c -fstrict-aliasing -Wall", I get:
b.c: In function `bar':
b.c:8: warning: dereferencing type-punned pointer will break strict-aliasing rules
I get this for x86-64, ia64, ppc64 and sparc64.
However, if I compile for a 32-bit target (I've tried i386 and ppc32)
with the same options, I get no warnings.
It seems the warning is spurious, since nothing is being type-punned
and no aliases are being created.
Thanks,
Roland