From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>, Aldy Hernandez <aldyh@redhat.com>
Subject: [COMMITTED] Disable tree to bool conversion in frange::update_nan.
Date: Wed, 12 Oct 2022 08:50:48 +0200 [thread overview]
Message-ID: <20221012065050.412900-3-aldyh@redhat.com> (raw)
In-Reply-To: <20221012065050.412900-1-aldyh@redhat.com>
We have a set_nan(type) method which can be confused with
update_nan(bool) because of the silent conversion of pointers to bool.
Currently, if you call update_nan(tree), you'll set the possibility of
NAN with a sign of true if tree is non-null. This is prone to error
and this patch disallows this behavior.
gcc/ChangeLog:
* value-range.cc (frange::set_nonnegative): Pass bool to
update_nan.
* value-range.h: Disallow conversion to bool in update_nan().
---
gcc/value-range.cc | 2 +-
gcc/value-range.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index e07d2aa9a5b..26a2b782e2c 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -779,7 +779,7 @@ frange::set_nonnegative (tree type)
// Set +NAN as the only possibility.
if (HONOR_NANS (type))
- update_nan (/*sign=*/0);
+ update_nan (/*sign=*/false);
}
// Here we copy between any two irange's. The ranges can be legacy or
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 9d630e40f78..cb5e9d0522c 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -317,6 +317,7 @@ public:
const REAL_VALUE_TYPE &upper_bound () const;
void update_nan ();
void update_nan (bool sign);
+ void update_nan (tree) = delete; // Disallow silent conversion to bool.
void clear_nan ();
// fpclassify like API
--
2.37.3
next prev parent reply other threads:[~2022-10-12 6:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 6:50 [COMMITTED] Add default relation_kind to floating point range-op entries Aldy Hernandez
2022-10-12 6:50 ` [COMMITTED] Add an frange(type) constructor analogous to the irange version Aldy Hernandez
2022-10-12 6:50 ` Aldy Hernandez [this message]
2022-10-12 6:50 ` [COMMITTED] Add method to query the sign of a NAN Aldy Hernandez
2022-10-12 6:50 ` [COMMITTED] Add stubs for floating point range-op tests Aldy Hernandez
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=20221012065050.412900-3-aldyh@redhat.com \
--to=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@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).