https://gcc.gnu.org/bugzilla/show_bug.cgi?id=13049
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2007-07-09 05:21:45 |2017-2-27 CC| |msebor at gcc dot gnu.org Known to fail| |3.3, 4.5.3, 4.8.3, 4.9.3, | |5.3.0, 6.3.0, 7.0 --- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- The strict aliasing rule requires that An object shall have its stored value accessed only by an lvalue expression that has one of the following types ... The test case in comment #0 doesn't involve accessing the stored value of an object so it doesn't violate those rules. The following slightly modified version of the test case that does access the stored value of an object by an incompatible type and thus violate those rules is also not diagnosed, even by GCC 7. $ cat t.c && gcc -O2 -S -Wall -Wextra -Wpedantic -Wstrict-aliasing=3 -fstrict-aliasing -fdump-tree-optimized=/dev/stdout t.c struct tt { struct { short i, j; } t; }; int t (struct tt *i) { i->t.i = 1; i->t.j = 2; return *(int*)i; // violation here } ;; Function int t(tt*) (_Z1tP2tt, funcdef_no=0, decl_uid=2282, cgraph_uid=0, symbol_order=0) int t(tt*) (struct tt * i) { int _5; <bb 2> [100.00%]: MEM[(short int *)i_2(D)] = 131073; _5 = MEM[(int *)i_2(D)]; return _5; }