[Bug c/46742] -Wparentheses unexpectedly misses some cases [-Wbool-bitwise-parentheses]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46742 Eric Gallager changed: What|Removed |Added Blocks||87403 Summary|-Wparentheses unexpectedly |-Wparentheses unexpectedly |misses some cases |misses some cases ||[-Wbool-bitwise-parentheses ||] --- Comment #6 from Eric Gallager --- (In reply to Franz Sirl from comment #5) > Actually, after seeing a large bunch of justified warnings in our codebase > with the disabled APPEARS_TO_BE_BOOLEAN_EXPR_P check, I wonder if a new > option like -Wbool-bitwise-parentheses (thus not depending on the logical > NOT) would make sense? > > Note that this is heavily influenced by my code reading/code debugging POV, > I really hate it if I need lots of context to decide whether a statement in > a codebase unknown to me is correct or not. A warning like > -Wbool-bitwise-parentheses encourages programmers to make their intention > clear from the start. Or, in the best case, even uncovers coding bugs or > typos early. Making this block the "new-warning" bug then Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403 [Bug 87403] [Meta-bug] Issues that suggest a new warning
[Bug c/46742] -Wparentheses unexpectedly misses some cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46742 --- Comment #5 from Franz Sirl --- Actually, after seeing a large bunch of justified warnings in our codebase with the disabled APPEARS_TO_BE_BOOLEAN_EXPR_P check, I wonder if a new option like -Wbool-bitwise-parentheses (thus not depending on the logical NOT) would make sense? Note that this is heavily influenced by my code reading/code debugging POV, I really hate it if I need lots of context to decide whether a statement in a codebase unknown to me is correct or not. A warning like -Wbool-bitwise-parentheses encourages programmers to make their intention clear from the start. Or, in the best case, even uncovers coding bugs or typos early.
[Bug c/46742] -Wparentheses unexpectedly misses some cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46742 --- Comment #4 from Franz Sirl --- APPEARS_TO_BE_BOOLEAN_EXPR_P was introduced with r141340 (PR 7543), but I cannot find a discussion on why this suppression makes sense. When I disable it I only see 3 places where it triggers in trunk: gcc/cp/lex.c:115:24: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses] libdecnumber/decNumber.c:6036:11: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses] libgcc/libgcc2.c:1949:36: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses] To my eyes in all 3 cases a '&&' would be clearer, so the warning shouldn't be suppressed? If changing the behaviour of -Wparentheses after this long time is considered a problem, maybe we could add the stricter check to the relatively new -Wlogical-not-parentheses like clang? Note: clang documents -Wlogical-not-parentheses for comparison AND bitwise operators, GCC only for comparison operators.
[Bug c/46742] -Wparentheses unexpectedly misses some cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46742 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #3 from Marek Polacek --- We only warn if the second operand is !APPEARS_TO_BE_BOOLEAN_EXPR_P, but 1 appears to be a boolean expression.
[Bug c/46742] -Wparentheses unexpectedly misses some cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46742 Eric Gallager changed: What|Removed |Added CC||egall at gwmail dot gwu.edu --- Comment #2 from Eric Gallager --- (In reply to Mikael Pettersson from comment #0) > > Side note, shouldn't there be a "diagnostic" component in bugzilla? For now > I chose "C frontend", which may or may not be appropriate. You can put "diagnostic" under "keywords" instead
[Bug c/46742] -Wparentheses unexpectedly misses some cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46742 Franz Sirl changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-07-05 CC||sirl at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Franz Sirl --- Still happens with 7.1.1 and trunk. clang catches both with the -Wlogical-not-parentheses option.