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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org
           Keywords|                            |wrong-code
           Priority|P3                          |P2
   Target Milestone|---                         |11.4
            Summary|IPA modref breaks Safe      |[11/12/13 Regression] IPA
                   |Bitfields in C++            |modref breaks Safe
                   |                            |Bitfields in C++

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
[class.union] says that "At most one of the
non-static data members of an object of union type can be active at any time,
that is, the value of at most one of the non-static data members can be stored
in a union at any time.", however, it also has an exception:

"One special guarantee is made in order to simplify the use of unions: If a
standard-layout union contains several standard-layout structs that share a
common initial sequence ([class.mem]), and if a non-static data member of an
object of this standard-layout union type is active and is one of the
standard-layout structs, it is permitted to inspect the common initial sequence
of any of the standard-layout struct members"

so in this test, using the non-active union member doesn't trigger UB.  More
info at <https://preshing.com/20150324/safe-bitfields-in-cpp/>.

Reply via email to