https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115766

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The testcase is bogus.
As documented, you can't really take address of the different union members and
access interchangeably through such pointers.
In standard C/C++, only one union element is active, access to all the others
while another one is active are UB (unless you assign to a different one and
through that activate it).  So, union type punning is not valid in standard
C/C++ at all.
GCC as an extension allows type punning through unions, but only if the union
is visible in the access path.
See https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Type-punning

Reply via email to