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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:59c6831682dfa8bec2b5a62bdc85739924970808

commit r11-9080-g59c6831682dfa8bec2b5a62bdc85739924970808
Author: Patrick Palka <ppa...@redhat.com>
Date:   Tue Sep 14 11:22:12 2021 -0400

    c++: empty union member activation during constexpr [PR102163]

    Here, the union's constructor is defined to activate its empty data
    member _M_rest, but during constexpr evaluation of this constructor the
    subobject constructor call O::O(&_M_rest, 42) doesn't produce a side
    effect that actually activates the member, so the union still appears
    uninitialized after its constructor has run.  This patch fixes this by
    using a dummy MODIFY_EXPR in this situation, whose evaluation ensures
    the member gets activated.

            PR c++/102163

    gcc/cp/ChangeLog:

            * constexpr.c (cxx_eval_call_expression): After evaluating a
            subobject constructor call for an empty union member, produce a
            side effect that makes sure the member gets activated.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-empty17.C: New test.

    (cherry picked from commit de07cff96abd43f6f65dcf333958899c2ec42598)

Reply via email to