From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 8DA1938515F6; Wed, 12 Oct 2022 06:51:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DA1938515F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665557494; bh=wZNaYZ1136NLlA9GUSfmDvfs7aqyMEcT2PpVL9haW3Y=; h=From:To:Subject:Date:From; b=ppVsNomcu16dOOPfO3lp7b/F5nD33cVVFWHLpZBskqFmrx17rZfyMt65jjd0qdNaC 24q07QToFp6xAnWnQDbh9OWdxFsFn7aeD/ow4amzY8RwzS19GVcHS9gbO7O4be/0hH 7p8jPkfWwtYKbZqhGLrI25uTE8UqxRB5nNzGFuLo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3244] Disable tree to bool conversion in frange::update_nan. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: a901343aa314eb08b362fc6878456d12f96e49b7 X-Git-Newrev: 6ce0823721d476cabb2007fecc12c07202325e17 Message-Id: <20221012065134.8DA1938515F6@sourceware.org> Date: Wed, 12 Oct 2022 06:51:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6ce0823721d476cabb2007fecc12c07202325e17 commit r13-3244-g6ce0823721d476cabb2007fecc12c07202325e17 Author: Aldy Hernandez Date: Tue Oct 11 19:20:47 2022 +0200 Disable tree to bool conversion in frange::update_nan. 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(). Diff: --- 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