[cfe-dev] Diagnostic.h : Diagnostic::Report line 836

Michael Mullin masmullin at gmail.com
Wed Nov 3 08:54:04 PDT 2010


On Tue, Nov 2, 2010 at 1:05 PM, John McCall <rjmccall at apple.com> wrote:

> 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?
>
>
Yes that was why I was getting a crash. Thanks for the tip.  No there was
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.
>
>
:) yup, you are correct.  Thank you.


> John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101103/72b8696e/attachment.html>


More information about the cfe-dev mailing list