[cfe-commits] r148348 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/Sema.cpp lib/Sema/SemaDeclCXX.cpp

Richard Smith richard at metafoo.co.uk
Thu Jan 26 13:17:35 PST 2012


On Thu, Jan 26, 2012 at 12:00 PM, Sebastian Redl <
sebastian.redl at getdesigned.at> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120126/a951868f/attachment.html>


More information about the cfe-commits mailing list