[Bug c/51894] New: Fail to warn on likely precedence error in conditional
aravindvijayan224185 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jan 18 20:00:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list