http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47026

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-20 
12:03:12 UTC ---
(In reply to comment #0)
> 
>     /* temporary is being assigned to a const-reference : BAD */
>     const int* const &alias(ptr);

This is the correct behaviour, see 12.2 [class.temporary] paragraphs 4 and 5 in
the standard:

"4 There are two contexts in which temporaries are destroyed at a different
point than the end of the full-expression. ...
"5 The second context is when a reference is bound to a temporary. The
temporary to which the reference is bound or the temporary that is the complete
object to a subobject of which the temporary is bound persists for the lifetime
of the reference except as specified below."

The lifetime of the temporary ends on return from main, so the temporary also
ends when main returns.

Reply via email to