https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111575

            Bug ID: 111575
           Summary: -Wbool-operation mistakenly warns about an int
                    operation
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

Compile the following with 'gcc -Wall -O2 -S u.c' (gcc (GCC) 13.2.1 20230728
(Red Hat 13.2.1-1 on x86-64):

int
f (int x)
{
  return ~((int) !x);
}

It generate the following false positive:

u.c: In function ‘f’:
u.c:4:10: warning: ‘~’ on a boolean expression [-Wbool-operation]
    4 |   return ~((int) !x);
      |          ^
u.c:4:10: note: did you mean to use logical not?
    4 |   return ~((int) !x);
      |          ^
      |          !

The expression is an int expression, not a bool expression, so it should not be
warned about.

I put in the cast to pacify GCC's false alarm but the cast didn't work.

Reply via email to