From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5B1A6388B6BD; Tue, 18 Jul 2023 13:16:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B1A6388B6BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689686167; bh=UAi4eB8ftwzA2TmNBT9zdl1WXBCHEKi8Lg/Csl9pZ2I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RghntXaPnd0XxS1hJu5R4UTIdW2AVEcWA7IOnrj6nD1gJCWuEgNTMf3H86NRs+Y5v SJQnieDWU3eWrsEToTBEqFQvh0/yid0ymTbw5ePTLyvE0OmXEeFj5SxGZNPyThO3DJ 9BpMyb0zqPMZcfSZmV6Caqm986kwyb3APjauUug0= From: "pkeir at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110714] constexpr lifetime error: base class this pointer Date: Tue, 18 Jul 2023 13:16: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: 14.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: pkeir at outlook dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110714 --- Comment #3 from Paul Keir --- Actually, there's no need here to delete through the base pointer; so this = is perhaps simpler: struct Base { constexpr Base* get_this() { return this; } int x; }; struct Derived : public Base {}; constexpr bool test() { Derived* pf =3D new Derived; delete static_cast(pf->get_this()); return true; } constexpr bool b =3D test();=