[webkit-dev] PSA: Don't try to hold onto temporaries with references

Peter Kasting pkasting at chromium.org
Sun Oct 3 18:36:45 PDT 2010


On Sun, Oct 3, 2010 at 10:31 AM, Darin Adler <darin at apple.com> wrote:

> What you say here about object lifetime is not correct. I thought the same
> thing a year or so back. But the C++ language keeps these objects alive
> until the end of the block.
>

Correct.  One helpful section from the standard (12.2/5 "Temporary
objects"):

"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. A temporary bound
to a reference member in a constructor’s ctor-initializer (12.6.2) persists
until the constructor exits. A temporary bound to a reference parameter in a
function call (5.2.2) persists until the completion of the full expression
containing the call."

Adam's changes will not make any functional difference.

PK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20101003/72921aea/attachment.html>


More information about the webkit-dev mailing list