<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 28, 2015 at 10:38 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 1:23 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Apr 28, 2015 at 10:11 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> On Tue, Apr 28, 2015 at 12:22 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>><br>
>> wrote:<br>
>> > On Tue, Apr 28, 2015 at 5:36 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
>> > 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>
>> 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>
><br>
><br>
> Can sometimes make a reasonable guess based on the diagnostic style/text -<br>
> though GCC 5-ish has started doing the quoted samples like Clang (though it<br>
> doesn't highlight ranges, so that's still a distinguishing feature even in<br>
> non-colored output)<br>
<br>
</span>Yeah, that's why I was guessing GCC. Doesn't look like Clang output to me.<br>
<span class=""><br>
><br>
>><br>
>><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>
>> Correct, that's why I called it a spurious warning. ;-)<br>
><br>
><br>
> Ah, sorry, missed that.<br>
><br>
>><br>
>><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>
>> 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>
><br>
><br>
> Disable bad warnings - we've certainly disabled a few of GCC's for just this<br>
> reason before, I'm surprised this variation on the theme has survived this<br>
> long, honestly (I guess -Wmaybe-uninitialized was the biggest culprit).<br>
<br>
</span>I don't think this warning is a reasonable candidate to disable based<br>
on how infrequently we run into FPs with it.<br></blockquote><div><br>My tolerance is fairly low because it seems it doesn't buy us much, so even a small false positive count seems enough to disable it when we'll catch the good cases with clang anyway. (& it means I don't have to worry about missing a code review motivated by the warning)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> If we really want to avoid that, you could pull out the switch into a helper<br>
> function that you call to retrieve the desired value. The llvm_unreachable<br>
> will stop GCC from warning about -Wreturn-type and the variable initialized<br>
> with the result of the call will be always initialized. (& then different<br>
> sanitizers would catch the sort of bugs that would lead to the unreachable<br>
> or otherwise exiting the function without a return value) - also makes the<br>
> code easier to read/reason about, since you don't have to scan the switch to<br>
> check that the variable's initialized.<br>
<br>
</span>This seems reasonable. I've implemented it in r236002. Thank you for<br>
the suggestion!<br></blockquote><div><br>cool cool :)<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>
> - David<br>
><br>
>><br>
>><br>
>> ~Aaron<br>
>><br>
>> ><br>
>> >><br>
>> >> Modified:<br>
>> >>     cfe/trunk/lib/Sema/SemaLambda.cpp<br>
>> >><br>
>> >> Modified: cfe/trunk/lib/Sema/SemaLambda.cpp<br>
>> >> URL:<br>
>> >> <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>
>> >> ==============================================================================<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>
><br>
><br>
</div></div></blockquote></div><br></div></div>