This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/32587] New: gcc fails to issue "warning: suggest parentheses around assignment used as truth value"


This c code:

// begin ok.c
int bar(int a, int b, int c)
{
    //if ((b = c) && (a == 0))
    if (b = c)
        {
        return 0;
        }
    return 1;
}
// end ok.c

When compiled with 

gcc -Wall -c ok.c

issues this warning:

ok.c: In function `bar':
ok.c:5: warning: suggest parentheses around assignment used as truth value

That is what I expect.

This code, however does not issue the warning:
// begin bad.c
int bar(int a, int b, int c)
{
    if ((b = c) && (a == 0))
        {
        return 0;
        }
    return 1;
}
// end bad.c

gcc -Wall -c bad.c

(no output)


-- 
           Summary: gcc fails to issue "warning: suggest parentheses around
                    assignment used as truth value"
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fritz at intrinsity dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32587


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]