This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/29280] misleading warning for assignment used as truth construct
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 16 Apr 2016 00:41:35 +0000
- Subject: [Bug c/29280] misleading warning for assignment used as truth construct
- Auto-submitted: auto-generated
- References: <bug-29280-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29280
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2010-02-21 00:38:52 |2016-4-15
CC| |msebor at gcc dot gnu.org
Known to fail| |4.0.0, 4.5.3, 4.8.3, 4.9.3,
| |5.3.0, 6.0
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
It seems like it should be trivial to enhance the warning by adding a note with
the suggestion(s) mentioned in the request.
For reference, the following is what Clang prints:
$ cat t.c && clang -S -Wparentheses t.c
int f (int a, int b)
{
if (a = b)
return 1;
return 2;
}
t.c:3:11: warning: using the result of an assignment as a condition without
parentheses [-Wparentheses]
if (a = b)
~~^~~
t.c:3:11: note: place parentheses around the assignment to silence this warning
if (a = b)
^
( )
t.c:3:11: note: use '==' to turn this assignment into an equality comparison
if (a = b)
^
==
1 warning generated.