On Mon, Oct 4, 2010 at 12:41 PM, Hans Wennborg h...@chromium.org wrote:
On Mon, Oct 4, 2010 at 12:23 PM, Leandro Graciá Gil
leandrogra...@chromium.org wrote:
In summary, looking at code like this
B b = c-foo();
...
b.m();
If c-foo() returns a temporary (return B();), then it is safe.
In summary, looking at code like this
B b = c-foo();
...
b.m();
If c-foo() returns a temporary (return B();), then it is safe.
Maybe I'm wrong, but are you completely sure about this one? I would say
that the temporary object created in return B() will cease to exist as soon
as it
On Mon, Oct 4, 2010 at 12:23 PM, Leandro Graciá Gil
leandrogra...@chromium.org wrote:
In summary, looking at code like this
B b = c-foo();
...
b.m();
If c-foo() returns a temporary (return B();), then it is safe.
Maybe I'm wrong, but are you completely sure about this one? I would say
Date: Mon, 4 Oct 2010 12:23:06 +0100
From: leandrogra...@chromium.org
To: le...@google.com
CC: webkit-dev@lists.webkit.org
Subject: Re: [webkit-dev] PSA: Don't try to hold onto temporaries with
references
In summary, looking at code like this
B b = c
The standard is clear on this. The temporary does persist for the lifetime of
the reference.
See https://bugs.webkit.org/show_bug.cgi?id=47055#c4, a comment I posted
yesterday morning, for the reference to the appropriate section in the C++
standard.
-- Darin
On Mon, Oct 4, 2010 at 4:23 AM, Leandro Graciá Gil
leandrogra...@chromium.org wrote:
In summary, looking at code like this
B b = c-foo();
...
b.m();
If c-foo() returns a temporary (return B();), then it is safe.
Maybe I'm wrong, but are you completely sure about this one? I would
On Tue, Oct 5, 2010 at 3:42 AM, Peter Kasting pkast...@chromium.org wrote:
On Mon, Oct 4, 2010 at 4:23 AM, Leandro Graciá Gil
leandrogra...@chromium.org wrote:
In summary, looking at code like this
B b = c-foo();
...
b.m();
If c-foo() returns a temporary (return B();), then it is
If a function returns a temporary, you probably don't want to hold
onto it with a const Foo foo. The temporary will get deallocated
and then you'll be left with a reference to dead memory, which is bad
new bears:
http://trac.webkit.org/changeset/68984
http://trac.webkit.org/changeset/68985
This
On Oct 3, 2010, at 2:21 AM, Adam Barth wrote:
If a function returns a temporary, you probably don't want to hold onto it
with a const Foo foo. The temporary will get deallocated
and then you'll be left with a reference to dead memory, which is bad new
bears:
I don’t understand why the
On Sun, Oct 3, 2010 at 10:31 AM, Darin Adler da...@apple.com wrote:
On Oct 3, 2010, at 2:21 AM, Adam Barth wrote:
If a function returns a temporary, you probably don't want to hold onto it
with a const Foo foo. The temporary will get deallocated
and then you'll be left with a reference to
On 10/04/2010 01:31 AM, Darin Adler 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. Some other programmers on the project challenged me
when I made this
On Sun, Oct 3, 2010 at 10:31 AM, Darin Adler da...@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
Thanks Peter and Darin.
In summary, looking at code like this
B b = c-foo();
...
b.m();
If c-foo() returns a temporary (return B();), then it is safe.
If c-foo() returns a reference to a member variable (return m_b;), then
it is up to the lifetime of of c-m_b.
The cases that Adam changed
13 matches
Mail list logo