<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 28, 2015 at 10:11 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Apr 28, 2015 at 12:22 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
> On Tue, Apr 28, 2015 at 5:36 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br>
>> Author: aaronballman<br>
>> Date: Tue Apr 28 07:36:54 2015<br>
>> New Revision: 235981<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=235981&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=235981&view=rev</a><br>
>> Log:<br>
>> Silencing a spurious -Wuninitialized warning with this local; NFC.<br>
><br>
> Which compiler warned on this?<br>
<br>
</span>I believe it's gcc, but I do not have the version information handy.<br>
It's the bot responsible for building our attribute documentation,<br>
which I keep warning-free. (Tanya would probably be able to get that<br>
information for us if it was important.)<br></blockquote><div><br>Can sometimes make a reasonable guess based on the diagnostic style/text - though GCC 5-ish has started doing the quoted samples like Clang (though it doesn't highlight ranges, so that's still a distinguishing feature even in non-colored output)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> It looks like this initialization is not needed - the switch over<br>
> ImpCaptureStyle (speaking of which, the declaration of this variable<br>
> could be moved down to closer to this switch - it isn't used before<br>
> the switch) seems to initialize the variable on all paths that are<br>
> reachable.<br>
<br>
</span>Correct, that's why I called it a spurious warning. ;-)<br></blockquote><div><br>Ah, sorry, missed that.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> (the usual "excessive initialization hampers checkers like msan and<br>
> doesn't make the code better because the default value is never<br>
> intended to be used - so the program's already off the rails if it's<br>
> used")<br>
<br>
</span>Also agreed. If you have a better idea of how to silence the warning<br>
so that build remains warning-free, I would welcome suggestions.<br></blockquote><div><br>Disable bad warnings - we've certainly disabled a few of GCC's for just this reason before, I'm surprised this variation on the theme has survived this long, honestly (I guess -Wmaybe-uninitialized was the biggest culprit).<br><br>If we really want to avoid that, you could pull out the switch into a helper function that you call to retrieve the desired value. The llvm_unreachable will stop GCC from warning about -Wreturn-type and the variable initialized with the result of the call will be always initialized. (& then different sanitizers would catch the sort of bugs that would lead to the unreachable or otherwise exiting the function without a return value) - also makes the code easier to read/reason about, since you don't have to scan the switch to check that the variable's initialized.<br><br>- David<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
>><br>
>> Modified:<br>
>>     cfe/trunk/lib/Sema/SemaLambda.cpp<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/SemaLambda.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=235981&r1=235980&r2=235981&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=235981&r1=235980&r2=235981&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/SemaLambda.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/SemaLambda.cpp Tue Apr 28 07:36:54 2015<br>
>> @@ -1482,7 +1482,7 @@ ExprResult Sema::BuildLambdaExpr(SourceL<br>
>>    // Collect information from the lambda scope.<br>
>>    SmallVector<LambdaCapture, 4> Captures;<br>
>>    SmallVector<Expr *, 4> CaptureInits;<br>
>> -  LambdaCaptureDefault CaptureDefault;<br>
>> +  LambdaCaptureDefault CaptureDefault = LCD_None;<br>
>>    SourceLocation CaptureDefaultLoc;<br>
>>    CXXRecordDecl *Class;<br>
>>    CXXMethodDecl *CallOperator;<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>