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

            Bug ID: 95156
           Summary: -Wtautological-compare warns in C but not C++
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon.marchi at polymtl dot ca
  Target Milestone: ---

Any reason why this code:

volatile unsigned short insn;

int main()
{
  if ((insn & 0xffb0) == 0xe950) {
      return 1;
  } else {
      return 0;
  }
}

warns when compiled with gcc:

$ gcc-10 test.c -c -Wall
test.c: In function ‘main’:
test.c:5:23: warning: bitwise comparison always evaluates to false
[-Wtautological-compare]
    5 |   if ((insn & 0xffb0) == 0xe950) {
      |  

but not when compiled with g++:

$ g++-10 test.c -c -Wall
<nothing>

?

Reply via email to