This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems
- From: "fn_x at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jul 2005 23:33:20 -0000
- Subject: [Bug c/23106] New: -Wstrict-aliasing=2 doesn't warn for all aliasing problems
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
This program:
int main() {
int a = 1;
* (short *) (char *) &a = 2;
char *p = (char *) &a;
* (short *) p = 3;
return a;
}
returns 1 when compiled with gcc 4.0.1 (nothing more is necessary than gcc -O2
test.c). However, adding -Wstrict-aliasing=2 does not make any warning for this
show up. This happens with void * as well.
I first asked about the first case on gcc-help, and Ian Lance Taylor followed up
with a patch to show a warning:
http://gcc.gnu.org/ml/gcc-help/2005-07/msg00292.html
For the second case, he asked to open a bug here.
--
Summary: -Wstrict-aliasing=2 doesn't warn for all aliasing
problems
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fn_x at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23106