From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0E93B3858D37; Mon, 22 May 2023 22:41:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E93B3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684795306; bh=BRmyMXUUPK1VRuUwqaPUiYW6mF8YCVVTF9jcYjjFvuA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=e1jZqjdw9Y0d54aq1VtFXT8hKstkGHz5rO4Zi6PTBwY7IgBjQRfFjaP2jRMVO/dpK piEnt3OgdlAhPMLgUDD9c7sSI5wkk+LPCcZ0A5QuIts13HiTsM4Yx66rL0rXv784/a mMEj84lQn7FKjHcPsncvqbwgw5QZmoyXaGN7Qp9A= From: "herring at lanl dot gov" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/91317] [7/8/9/10 Regression] false-positive maybe-uninitialized warning in destructor with placement new Date: Mon, 22 May 2023 22:41:44 +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: 8.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: herring at lanl dot gov X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: cc 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=3D91317 S. Davis Herring changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |herring at lanl dot gov --- Comment #4 from S. Davis Herring --- My understanding is that code like this is just inherently unsafe in the presence of exceptions: the old U's lifetime ends as soon as the constructor call begins, without running its destructor ([basic.life]/5), and if a() th= rows the lifetime of the new U never begins (/1.2), so the automatic destructor = call is UB (/9). I'd want a warning for any such reinitialization where the potential except= ion would definitely destroy the stranded object, and probably even if another destructor might intervene and terminate the program. More difficult would= be to handle the case of catching such an exception and trying to resurrect the object again, possibly via a non-throwing constructor.=