Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-02-11 22:10:27


"Eric Niebler" <eric_at_[hidden]> wrote

> Vertleyb wrote:

> > I am still not sure though, if the lifetime is extended far enough for
this case,
> > or does this just work correctly by accident...
> > (have to take a closer look into the Standard)
> >
> This is broken. f() returns a temporary, which is bound to a const ref
> and has its lifetime extended to the end of the scope containing the
> const ref. So when ff() returns, the temporary object will be cleaned
> up, so ff() is returning a dead reference. If you use an object with a
> destructor instead of int, you can set a breakpoint to verify.

I see... So, this makes my original assumption wrong :-(

Any luck with telling const x from const x&?

Regards,
Arkadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk