public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/91317] [7/8/9/10 Regression] false-positive maybe-uninitialized warning in destructor with placement new
       [not found] <bug-91317-4@http.gcc.gnu.org/bugzilla/>
@ 2023-05-22 22:41 ` herring at lanl dot gov
  0 siblings, 0 replies; only message in thread
From: herring at lanl dot gov @ 2023-05-22 22:41 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-22 22:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91317-4@http.gcc.gnu.org/bugzilla/>
2023-05-22 22:41 ` [Bug c++/91317] [7/8/9/10 Regression] false-positive maybe-uninitialized warning in destructor with placement new herring at lanl dot gov

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).