public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111575] New: -Wbool-operation mistakenly warns about an int operation
@ 2023-09-24 20:06 eggert at cs dot ucla.edu
  0 siblings, 0 replies; only message in thread
From: eggert at cs dot ucla.edu @ 2023-09-24 20:06 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-24 20:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-24 20:06 [Bug c/111575] New: -Wbool-operation mistakenly warns about an int operation eggert at cs dot ucla.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).