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: unassig...@gcc.gnu.org
        ReportedBy: aravindvijayan224...@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.

Reply via email to