public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dcb314 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/105581] New: boolean types and relational operators problem
Date: Thu, 12 May 2022 10:11:03 +0000	[thread overview]
Message-ID: <bug-105581-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2022-05-12 10:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 10:11 dcb314 at hotmail dot com [this message]
2022-05-12 10:23 ` [Bug c/105581] " pinskia at gcc dot gnu.org
2022-05-12 10:46 ` schwab@linux-m68k.org
2022-05-12 11:49 ` dcb314 at hotmail dot com
2022-05-12 12:12 ` schwab@linux-m68k.org
2022-10-27  6:45 ` [Bug c/105581] new warning about boolean types and relational operators pinskia at gcc dot gnu.org
2022-10-27  6:45 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105581-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).