varargs, 64-bit targets, and strict-aliasing warnings
Joseph S. Myers
jsm@polyomino.org.uk
Fri Aug 27 02:50:00 GMT 2004
On Thu, 26 Aug 2004, Roland Dreier wrote:
> 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
uint64_t is unsigned long rather than unsigned long long on those 64-bit
targets. Thus the pointer cast creates a pointer which foo cannot safely
dereference without converting back to a pointer to uint64_t.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
More information about the Gcc
mailing list