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 crashes were happening here and why your code 
changes were helpful.

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 assertion, and we found that I was wrong and they were right.

But that doesn’t explain why the code was crashing!

    -- Darin

_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to