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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Sergei Trofimovich from comment #0)
>   input_files.emplace_back(Z{
>       arg.str(), // what is the lifetime of this temporary?

This prvalue initializes the 'name' member of the Z temporary, there is no
separate string temporary.

>       to_stage(arg), // why does this constructor matter?

My fix for PR66139 fixed EH in aggregate initialization so that if evaluation
of to_stage(arg) throws, we properly destroy the previously initialized 'name'
member.  That's the difference pinskia mentions.

It is surprising that we warn with a user-provided copy constructor and don't
with a defaulted constructor.  It changes the code a bit because it means
string_piece isn't trivially copyable, so we need to create a string_piece
temporary for passing to to_stage instead of passing arg directly by bitwise
copy, but I don't know why that would confuse the optimizers into thinking that
_M_p might be uninitialized.

Reply via email to