From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2DB03389681B; Mon, 10 Jan 2022 19:59:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DB03389681B From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103879] error: accessing value of variant::_Copy_ctor_base through a 'const variant' glvalue in a constant expression Date: Mon, 10 Jan 2022 19:59:07 +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: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Mon, 10 Jan 2022 19:59:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103879 --- Comment #11 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:ab36b554bd90e8db279d13b133369118814f13fb commit r12-6425-gab36b554bd90e8db279d13b133369118814f13fb Author: Patrick Palka Date: Mon Jan 10 14:57:54 2022 -0500 c++: constexpr base-to-derived conversion with offset 0 [PR103879] r12-136 made us canonicalize an object/offset pair with negative offset into one with a nonnegative offset, by iteratively absorbing the innermost component into the offset and stopping as soon as the offset becomes nonnegative. This patch strengthens this transformation by making it keep on absorbi= ng even if the offset is already 0 as long as the innermost component is at position 0 (and thus absorbing doesn't change the offset). This lets us accept the two constexpr testcases below, which we'd previously reject essentially because cxx_fold_indirect_ref would be unable to resolve *(B*)&b.D123 (where D123 is the base A subobject at position 0) to just= b. PR c++/103879 gcc/cp/ChangeLog: * constexpr.c (cxx_fold_indirect_ref): Split out object/offset canonicalization step into a local lambda. Strengthen it to absorb more components at position 0. Use it before both calls to cxx_fold_indirect_ref_1. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-base2.C: New test. * g++.dg/cpp1y/constexpr-base2a.C: New test.=