From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B635C3844044; Mon, 26 Apr 2021 21:31:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B635C3844044 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100209] multiple inheritance with crtp pattern fails on sequentioal member access Date: Mon, 26 Apr 2021 21:31:33 +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: 10.2.1 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, 26 Apr 2021 21:31:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100209 --- Comment #4 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3 commit r12-136-g0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3 Author: Patrick Palka Date: Mon Apr 26 17:30:39 2021 -0400 c++: constexpr pointer indirection with negative offset [PR100209] During constexpr evaluation, a base-to-derived conversion may yield an expression like (Derived*)(&D.2217.D.2106 p+ -4) where D.2217 is the derived object and D.2106 is the base. But cxx_fold_indirect_ref doesn't know how to resolve an INDIRECT_REF thereof to just D.2217, because it doesn't handle POINTER_PLUS_EXPR of a COMPONENT_REF with negative offset well: when the offset N is positive, it knows that '&x p+ N' is equivalent to '&x.f p+ (N - bytepos(f))', but it doesn't know about the reverse transformation, that '&x.f p+ N' is equivalent to '&x p+ (N + bytepos(f))' when N is negative, which is important for resolving such base-to-derived conversions and for accessing subobjects backwards. This patch teaches cxx_fold_indirect_ref this reverse transformation. gcc/cp/ChangeLog: PR c++/100209 * constexpr.c (cxx_fold_indirect_ref): Try to canonicalize the object/offset pair for a POINTER_PLUS_EXPR of a COMPONENT_REF with a negative offset into one whose offset is nonnegative before calling cxx_fold_indirect_ref_1. gcc/testsuite/ChangeLog: PR c++/100209 * g++.dg/cpp1y/constexpr-base1.C: New test. * g++.dg/cpp1y/constexpr-ptrsub1.C: New test.=