[cfe-dev] Diagnostic.h : Diagnostic::Report line 836
John McCall
rjmccall at apple.com
Tue Nov 2 10:05:13 PDT 2010
On Nov 2, 2010, at 9:46 AM, Michael Mullin wrote:
> The following code is adapted from an online clang tutorial. It will seg fault if it Lexes itself.
>
> The seg fault happens somewhere in the vicinity of Preprocessor.h Diag() (line 625/631) and the function that I posted below.
I'm pretty sure you need to set a DiagnosticClient on the Diagnostic object; that is probably why you're getting a crash. Is there not an assert about this?
> My compiler could be choosing not to inline the function, thus the DiagnosticBuilder(this) that is created will be destroyed as the function is popped off the call-stack. Thus using the return value of this function will cause a fault.
The struct is being returned by value, so the caller gets a copy. That's how C++ works.
John.
More information about the cfe-dev
mailing list