https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118141
--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Richard Yao from comment #14) > A few final questions: > > What is the purpose of a union type if type punning is undefined behavior in > the standard? To save space. To make classes like structures in C (GCC does this for their tree and rtl structures). Note there are rules dealing with common parts of unions which I did not reference here for simplicity reasons. > If I specify -std=c99, should I expect type punning via union > types to break on me? As I said GCC documents it as being defined (even with -std=xx). > > Is there any documentation for how the strict aliasing rule interacts with > compiler intrinsics? In specific, would this be undefined behavior too or > does using the memcpy() instead of _mm_storeu_si128() make it okay? _mm_storeu_si128 is defined by the Intel intrinsics rules. See https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_storeu_si128&ig_expand=6546 And in this since it does not specify a type, GCC assumes to be may_alias all types. In fact the typedef __m128i type in GCC's intrinsics header has the may_alias attribute on it. That is another option for you to use is the may_alias attribute which is again outside of C/C++ standard.