https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80652
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Peter Boyle from comment #6) > Just a comment -- suggest a warning thrown if union access from > two views is made. AFAIK g++ is the only compiler not implementing the > defacto type pun use. > > http://en.cppreference.com/w/cpp/language/union > > "Many compilers implement, as a non-standard language extension, the ability > to read inactive members of a union." Actually it does except you are accessing not directly from the union but rather than via a pointer (reference) which is where the problem comes in. Just change: "const scalar &a" to be "const scalar a" and you see the behavior you originally expected.