On Thu, Jan 26, 2012 at 12:00 PM, Sebastian Redl <
[email protected]> wrote:

>
> On 18.01.2012, at 22:39, Richard Smith wrote:
>
> On Wed, January 18, 2012 01:31, Sebastian Redl wrote:
>
> "The lifetime of the array is the same as that of the initializer_list
>
> object." So if a temporary is constructed, wouldn't the lifetime of the
> array
>
> be that of the temporary?
>
>
> This is DR1290. If I understand correctly, the intent is that the lifetime
> of
> the array acts like initializer_list is a reference type binding to the
> array
> (under the rules in 12.2/5).
>
>
> Doesn't help with the new-expression situation, though, since you can't
> new a reference, so there are no existing rules.
>

That's not entirely true. Consider:

  struct S { const int &r; };
  S *p = new S { 0 }; // reference is bound to temporary which is destroyed
at end of full-expression

One consequence of this is that "new auto { ... }" is essentially always a
bug.

By the way, this issue appears empty to me in the list, i.e. no discussion
> or even description, just a title.
>

The WG21 internal version of this issue has some links to discussion on the
core reflector, but there's sadly not much information there either, other
than that initializer_list was supposed to have reference semantics.

- Richard
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to