/* x86 platform. This simple program with the obvious breaking of strict aliasing rules does not generate a warning with -Wstrict-aliasing gcc -Wall -Wstrict-aliasing test.c tested on Pentium 4 gcc 3.4.2, gcc 3.3.5 and gcc 3.2.3, as built for debian unstable 2004 Nov 9 */ #include <stdio.h> unsigned long hash(void *key) { unsigned long long u[1]; u[0] = *(unsigned long long *)key; return ((unsigned long *)u)[0] ^ ((unsigned long *)u)[1]; } int main(void) { unsigned long long ull; ull = 0xDEADBEAF; fprintf(stderr, "%08lX\n", hash(&ull)); return 0; }
-- Summary: -Wstrict-aliasing fails to report simple case of breaking strict aliasing rules Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: minor Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: torger at ludd dot luth dot se CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18426