public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-100209-4-bjL3GKBAPi@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100209-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100209 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3 commit r12-136-g0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3 Author: Patrick Palka <ppalka@redhat.com> 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.
next prev parent reply other threads:[~2021-04-26 21:31 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-22 12:48 [Bug c++/100209] New: " autumn.rain at mail dot ru 2021-04-22 13:14 ` [Bug c++/100209] " rguenth at gcc dot gnu.org 2021-04-23 2:51 ` ppalka at gcc dot gnu.org 2021-04-23 4:28 ` ppalka at gcc dot gnu.org 2021-04-23 4:29 ` ppalka at gcc dot gnu.org 2021-04-26 21:31 ` cvs-commit at gcc dot gnu.org [this message] 2021-04-28 2:34 ` ppalka at gcc dot gnu.org 2021-11-06 23:40 ` ppalka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100209-4-bjL3GKBAPi@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).