varargs, 64-bit targets, and strict-aliasing warnings

Roland Dreier roland@topspin.com
Fri Aug 27 01:34:00 GMT 2004


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



More information about the Gcc mailing list