On Wed, May 29, 2013 at 7:35 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Wunreachable-code doesn't warn on empty statement bodies for the<br>
switch.  So, for instance:<br>
<br>
int main() {<br>
  int i = 0;<br>
  switch(i) {}<br>
}<br>
<br>
yields no warnings in clang with -Wunreachable-code (or -Wall), but at<br>
/W3 in MSVC you get: warning C4060: switch statement contains no<br>
'case' or 'default' labels.  Will it catch lots of bugs?  Probably<br>
not.  But it also should have basically no false positives either.  It<br>
would be nice for people who want their code to also be warning-free<br>
under MSVC.</blockquote><div><br></div><div>I think we need more justification for adding the warning than this.</div><div><br></div><div>It doesn't seem reasonable to expect us to implement the union of all warnings which every existent compiler produces. Some of those warnings are really dumb. For instance, /W3 also enables C4800, which I don't think we will ever want to implement.</div>
<div><br></div><div>We already warn on:</div><div><br></div><div>  switch(i);</div><div><br></div><div>... and changing the ';' to '{}' is one of the ways we expect people to silence that warning, if (for whatever obscure reason) they really wanted a switch with no body.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, May 28, 2013 at 11:07 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>

> What kinds of bugs does this catch that -Wunreachable-code misses?<br>
><br>
> On Tue, May 28, 2013 at 8:27 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> This patch addresses PR4546; it warns when a switch statement contains<br>
>> a body, but the body does not contain any case or default labels.<br>
>><br>
>> ~Aaron<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>