https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78772
--- Comment #9 from ma.jiang at zte dot com.cn --- (In reply to Jim Wilson from comment #8) > Looking at the 2011 ISO C standard, section 6.5 Expressions, paragraph 7, > says "An object shall have its stored value accessed only by an lvalue > expression that has one of the following types:". It then lists compatible > types, a qualified compatible type, a signed/unsigned compatible type, a > signed/unsigned qualified compatible type, an aggregate/union that contains > a compatible type, or a char type. If your code conforms to this rule, then > -fstrict-aliasing will not break it. > > GCC supports type punning via unions. Or you can use -fno-strict-aliasing > if you want to use pointer casts for type punning. Hi Jim, Sorry for the delay, it really take me much time to read the standard(which it's not in my mother language, and hard to understand ...). Thanks a lot, I haven't noticed these pieces in c-11 standard before. It looks like that c-standard has required strict-alias since c-99. I think this fact should give us more reason to enable "-Wstrict-aliasing" by default. First, it's a violation of the c-standard. Moreover, it may generate broken binary.Obviously, this kind of warning is not similar to those "informational warnings" such as "-Wunused-variable". And by the way, the strict-alias thing is really a mess...The gcc manual should talk more about this(more right/wrong examples?). I am still not sure whether following codes(which are widely used...) are ok with strict-alias. extern char buf[32]; int *a = (int *)&(buf[16]); int result = *a; //is this ok? or we have to use memcpy(&result, &buf[16], sizeof(int))?