This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51894] New: Fail to warn on likely precedence error in conditional
- From: "aravindvijayan224185 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Jan 2012 19:19:52 +0000
- Subject: [Bug c/51894] New: Fail to warn on likely precedence error in conditional
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51894
Bug #: 51894
Summary: Fail to warn on likely precedence error in conditional
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: aravindvijayan224185@gmail.com
Created attachment 26371
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26371
example program showing the failure to warn
example program showing the failure to warn:
gcc version 4.7.0
If you have:
if (ret = return_neg_one() == 1)
printf("direct_test==true\n");
else
printf("direct_test==false\n");
The compiler will warn:
/tmp/tmp.c:51:2: warning: suggest parentheses around assignment used as truth
value
But if it is a complex conditional:
if (!cond ||
(ret = return_neg_one() == 1))
The compiler will not warn. It seems it should warn in this case as well.