public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "herring at lanl dot gov" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-91317-4-4hEAWaIBEw@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-91317-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91317 S. Davis Herring <herring at lanl dot gov> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |herring at lanl dot gov --- Comment #4 from S. Davis Herring <herring at lanl dot gov> --- 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() throws 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 exception 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.
parent reply other threads:[~2023-05-22 22:41 UTC|newest] Thread overview: expand[flat|nested] mbox.gz Atom feed [parent not found: <bug-91317-4@http.gcc.gnu.org/bugzilla/>]
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-91317-4-4hEAWaIBEw@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).