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