[cfe-dev] Undiagnosed "reference to stack memory [...] returned"

Eli Friedman eli.friedman at gmail.com
Wed Sep 15 12:05:14 PDT 2010


On Wed, Sep 15, 2010 at 11:32 AM, Ted Kremenek <kremenek at apple.com> wrote:
> I'm not certain this is a bug.  The 'const int&' causes the lifetime of the object returned from get_value() to be extended to its last use.  Does this extend to the caller of get_reference_no_warning_2() since that also returns a const reference?

In get_reference_no_warning_2, w2 is bound to a temporary which is
live for the lifetime of w2; returning a reference to the temporary
doesn't extend its lifetime.

-Eli




More information about the cfe-dev mailing list