[Bug c/106455] New: bad style: comparatives over booleans ?

dcb314 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jul 27 14:11:09 GMT 2022


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

            Bug ID: 106455
           Summary: bad style: comparatives over booleans ?
           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: ---

Static analyser cppcheck says for recent gcc trunk:

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

Source code is

      bool negative = m_sig < 0;
      bool other_negative = other.m_sig < 0;

      if (negative != other_negative)
        return negative > other_negative;

I agree - this looks bad style to me. I don't think > should work on booleans.


More information about the Gcc-bugs mailing list