[cfe-dev] GCC's "Temporaries May Vanish Before You Expect"
Jordan Rose
jordan_rose at apple.com
Wed Sep 12 17:11:28 PDT 2012
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.
>> I->getAs<CFGStmt>()
>>
>> and
>>
>> dyn_cast<CFGStmt>(&*I)
>>
>> , the latter of which is slightly more ugly.
>
> Would it be possible to make dyn_cast a bit smarter so that it will
> look into an iterator's member typedefs and automatically do the
> trivial &* stuff itself?
In theory, yes. In practice, I'm not sure if we want simplify_type to be that smart. I haven't thought it through, though.
More information about the cfe-dev
mailing list