This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: varargs, 64-bit targets, and strict-aliasing warnings
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Roland Dreier <roland at topspin dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 26 Aug 2004 23:52:32 +0000 (UTC)
- Subject: Re: varargs, 64-bit targets, and strict-aliasing warnings
- References: <52hdqpa2fp.fsf@topspin.com>
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)