[Bug c++/78522] -O2 optimization confused by enum and pointer usage in constructors.

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 25 11:35:00 GMT 2016


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Samuel T C Huang from comment #0)
>     helper.run(reinterpret_cast<uint32_t*>(&value_type));

The problem is here. This cast leads to an aliasing violation when you assign
through the pointer, so the program has undefined behaviour.

Don't do that.


More information about the Gcc-bugs mailing list