This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/29901] New: wrong warning with -Wstrict-aliasing/-fstrict-aliasing
- From: "wavexx at users dot sf dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Nov 2006 20:39:06 -0000
- Subject: [Bug c/29901] New: wrong warning with -Wstrict-aliasing/-fstrict-aliasing
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
$ gcc -Wstrict-aliasing -fstrict-aliasing -c test.c
test.c: In function ?f1?:
test.c:2: warning: dereferencing type-punned pointer will break strict-aliasing
rules
$ cat test.c
void f2(char **p);
void f1(unsigned char *bits) { f2((char **)&bits); };
$
but:
the same address as an object of a different type, unless the
types are almost the same. For example, an `unsigned int' can
alias an `int', but not a `void*' or a `double'. A character type
may alias any other type.
Signed/unsigned casts or casts to char should not produce a warning according
to the documentation.
--
Summary: wrong warning with -Wstrict-aliasing/-fstrict-aliasing
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wavexx at users dot sf dot net
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29901