public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106455] New: bad style: comparatives over booleans ?
@ 2022-07-27 14:11 dcb314 at hotmail dot com
  2022-07-27 14:45 ` [Bug c/106455] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2022-07-27 14:11 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-27 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 14:11 [Bug c/106455] New: bad style: comparatives over booleans ? dcb314 at hotmail dot com
2022-07-27 14:45 ` [Bug c/106455] " pinskia at gcc dot gnu.org
2022-07-27 15:07 ` schwab@linux-m68k.org
2022-07-27 15:15 ` dcb314 at hotmail dot com
2022-07-27 15:18 ` schwab@linux-m68k.org

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).