From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EFE16385AC30; Wed, 6 Oct 2021 14:15:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFE16385AC30 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102163] [10/11/12 Regression] std::variant rejects valid constant expression Date: Wed, 06 Oct 2021 14:15:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 14:15:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102163 --- Comment #5 from CVS Commits --- The releases/gcc-11 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:59c6831682dfa8bec2b5a62bdc85739924970808 commit r11-9080-g59c6831682dfa8bec2b5a62bdc85739924970808 Author: Patrick Palka 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)=