https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91317

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
If the first call to a() throws then no instance of U is constructed and so
neither U::~U() nor d() is called.

If the second call to a() throws then only the first instance of U will have
been constructed and its dtor called, but that instance's p will have been
initialized.

Does C++ say that the lifetime of an object (lhs in this case) ends as soon as
the construction of another object in the same storage begins, even when the
construction is not complete?  If that were the case, then throwing an
exception from the second invocation of U would either prevent the first U from
being destroyed, or trigger the destruction of the first instance just before
the exception was thrown, which is not what happens (when the exception is
caught).

Am I missing something?

Reply via email to