<br><br><div class="gmail_quote">On Tue, Nov 2, 2010 at 1:05 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Nov 2, 2010, at 9:46 AM, Michael Mullin wrote:<br>
> The following code is adapted from an online clang tutorial.  It will seg fault if it Lexes itself.<br>
><br>
> The seg fault happens somewhere in the vicinity of Preprocessor.h Diag() (line 625/631) and the function that I posted below.<br>
<br>
</div>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?<br>
<div class="im"><br></div></blockquote><div><br>Yes that was why I was getting a crash. Thanks for the tip.  No there was not an assert about this.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">
> 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.<br>

<br>
</div>The struct is being returned by value, so the caller gets a copy.  That's how C++ works.<br>
<font color="#888888"><br></font></blockquote><div><br>:) yup, you are correct.  Thank you.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888">
John.</font></blockquote></div><br>