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

            Bug ID: 105581
           Summary: boolean types and relational operators problem
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For this C code:

void g( int );

void f( bool a, bool b)
{
        if (a < b)
                g( 1);
}

recent gcc doesn't find a problem:

$ /home/dcb/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -pedantic may12a.cc
$

Here is cppcheck complaining:

$ /home/dcb/cppcheck/trunk.git/cppcheck --enable=all may12a.cc
may12a.cc:6:8: style: Comparison of a variable having boolean value using
relational (<, >, <= or >=) operator. [comparisonOfBoolWithBoolError]
 if (a < b)
       ^
$

There is an example in the gcc source code:

trunk.git/gcc/sreal.h:72:25: style: Comparison of a variable having boolean
value using relational (<, >, <= or >=) operator.
[comparisonOfBoolWithBoolError]

Source code is

        return negative > other_negative;

Reply via email to