Violating of strict-aliasing in C, even without any casting?
问题 How can *i and u.i print different numbers in this code, even though i is defined as int *i = &u.i; ? I can only assuming that I'm triggering UB here, but I can't see how exactly. (ideone demo replicates if I select 'C' as the language. But as @2501 pointed out, not if 'C99 strict' is the language. But then again, I get the problem with gcc-5.3.0 -std=c99 !) // gcc -fstrict-aliasing -std=c99 -O2 union { int i; short s; } u; int * i = &u.i; short * s = &u.s; int main() { *i = 2; *s = 100;