[cfe-dev] GCC's "Temporaries May Vanish Before You Expect"

Konstantin Tokarev annulen at yandex.ru
Thu Sep 13 03:16:00 PDT 2012

13.09.2012, 04:11, "Jordan Rose" <jordan_rose at apple.com>:
> On Sep 12, 2012, at 17:08 , Sean Silva <silvas at purdue.edu> wrote:
>>  Does that mean that:
>>  doSomething(StrRef.str().c_str());
>>  is unsafe?
>>  because I've seen a couple of those around.
> No, that's fine. Temporaries are destroyed "at the end of a full-expression", which is basically "the outermost expression". So the temporary will stay live until the call to doSomething completes.

However, doSomething should not save char * anywhere.


More information about the cfe-dev mailing list