[Bug c++/66476] Erroneous initializer_list lifetime extension from temporary initializer_list

2018-05-24 Thread ed at catmur dot uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66476

Ed Catmur  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |INVALID

--- Comment #3 from Ed Catmur  ---
Ah wait, guaranteed copy elision since C++17 should fix this, right? So g++ is
actually correct now, even if it was wrong before.

[Bug c++/66476] Erroneous initializer_list lifetime extension from temporary initializer_list

2018-05-24 Thread ed at catmur dot uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66476

Ed Catmur  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|INVALID |---

--- Comment #2 from Ed Catmur  ---
Yes... but the initializer_list that the array backs is itself temporary; it
has lifetime only for the duration of the call to the copy constructor. 

From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48562#c6 :

> I think that a warning against "({...})" would be useful too
>// fine
>initializer_list a{1, 2, 3};
>// this is bad
>initializer_list b({1, 2, 3});
> Second one is bad because it will destroy the array after initializing 'b', 
> and won't lengthen the lifetime (because it will use the copy/move
> constructor).

[Bug c++/66476] Erroneous initializer_list lifetime extension from temporary initializer_list

2018-05-22 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66476

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||jason at gcc dot gnu.org
 Resolution|--- |INVALID

--- Comment #1 from Jason Merrill  ---
11.6.4 [dcl.init.list] paragraph 6:

The array has the same lifetime as any other temporary object (15.2), except
that initializing an initializer_list object from the array extends the
lifetime of the array exactly like binding a reference to a temporary.

So the array shares the lifetime of the initializer_list.

[Bug c++/66476] Erroneous initializer_list lifetime extension from temporary initializer_list

2015-06-09 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66476

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-06-09
 Ever confirmed|0   |1