[Bug c/81402] unhelpful -Wparentheses suggestion for assignment from non-zero constant
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Sep 29 09:08:54 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81402
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-09-29
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, we should mention both cases just like clang does:
<source>:4:9: warning: using the result of an assignment as a condition without
parentheses [-Wparentheses]
if (i = j) { } // assignment could be intended
~~^~~
<source>:4:9: note: place parentheses around the assignment to silence this
warning
if (i = j) { } // assignment could be intended
^
( )
<source>:4:9: note: use '==' to turn this assignment into an equality
comparison
if (i = j) { } // assignment could be intended
^
==
<source>:9:9: warning: using the result of an assignment as a condition without
parentheses [-Wparentheses]
if (i = 1) { } // assignment almost certainly not intended
~~^~~
<source>:9:9: note: place parentheses around the assignment to silence this
warning
if (i = 1) { } // assignment almost certainly not intended
^
( )
<source>:9:9: note: use '==' to turn this assignment into an equality
comparison
if (i = 1) { } // assignment almost certainly not intended
^
==
More information about the Gcc-bugs
mailing list