This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/18426] New: -Wstrict-aliasing fails to report simple case of breaking strict aliasing rules
- From: "torger at ludd dot luth dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2004 06:32:34 -0000
- Subject: [Bug c/18426] New: -Wstrict-aliasing fails to report simple case of breaking strict aliasing rules
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
/*
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