[cfe-commits] [PATCH][PR11329] Generalize -Wempty-body: warn when statement body is a empty
Dmitri Gribenko
gribozavr at gmail.com
Wed Jan 4 11:44:31 PST 2012
On Wed, Jan 4, 2012 at 9:03 PM, Nico Weber <thakis at chromium.org> wrote:
> I ran this patch on a chromium build. It finds many false positives,
> [...] Since this pattern is apparently
> often used intentionally I'm not sure if this is a useful warning in
> practice.
I'm afraid of this running into a coding style argument (with a
compiler). Before we had -Wparenthethes in GCC people didn't write
parentheses around assignments that are also used as boolean values
and I'm sure some didn't like the noise they got when -Wparenthethes
got implemented.
I agree that we might want to reduce false positive rate for `for' and
`while' statements, but more elaborate ways (for example, checking if
the statement is followed by a CompoundStmt) would require shifting
this to static analyzer.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the cfe-commits
mailing list