From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A5F0A3858C74; Tue, 9 May 2023 09:34:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5F0A3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683624854; bh=vWCYau1EscDtYDE2883W1uYwQSRWMxWsMQ0yCtKnsyE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=og4vsO1RtIwpeSgWqz7j3BF/2lAGVhiXnzze0wKV42/T4En0+So29CYWLJMrVuXjs YhaTElYnHL0V+GwZ2XhpVeZXa7TFLtmssnzPxi29ujOeT/n8FlNOW9FihZgjzS/0YE 0od5SZ0xtiP1T32D5IQmy11/9kvbHMMbh7s5RW20= From: "m.cencora at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/109770] [10/11/12/13/14 Regression] wrong(?) devirtualization Date: Tue, 09 May 2023 09:34:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: m.cencora at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 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=3D109770 --- Comment #8 from m.cencora at gmail dot com --- (In reply to Richard Biener from comment #7) >=20 > Ah, interesting. I was looking for an answer whether >=20 > new T >=20 > may produce anything other than an object with dynamic type T or if there > are any constraints on the object constructed. In particular C++20 11.10= .4 > refered to by 6.7.3 doesn't mention whether re-using the storage is > permitted for an object under construction. It says usage is limited > and doesn't explicitely allow re-use so that might mean re-use is not > allowed. >=20 > Note std::launder is C++17 only, the original reporter was using C++98 / > C++14 >=20 > Reading C++20, 6.7.3/9, at least suggests that the placement new (this) A > in the CTOR invokes undefined behavior because the lifetime of B hasn't > ended (but 6.7.3/1.5 makes this ambiguous - we're re-using the storage he= re, > and also we're not talking about an object with automatic storage duratio= n). 6.7.3/9 doesn't apply to your example - this is not an automatic storage duration. If 11.10.4 is suppose to be an exhaustive allow-list, then yeah ending the complete object lifetime during its construction is UB, but I guess it woul= d be best to get a response from real C++ expert or file a C++ core issue.=