]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Disable tree to bool conversion in frange::update_nan.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 11 Oct 2022 17:20:47 +0000 (19:20 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 12 Oct 2022 06:48:59 +0000 (08:48 +0200)
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
gcc/value-range.h

index e07d2aa9a5bd5bf1dec6043d08ea75143cd46835..26a2b782e2cc70aed8f83f4d8805a082cf9cf0c1 100644 (file)
@@ -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
index 9d630e40f78a8ae92fd3e384cd18cad77105522e..cb5e9d0522ccba14a70d175fd76710b698b52c32 100644 (file)
@@ -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