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.

Reply via email to