From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 863CE385277E for ; Wed, 12 Oct 2022 06:51:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 863CE385277E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665557461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j5q4Xau6O6CMqm1WqltjGxdNWkAKOS1jlxQtD3MkTpk=; b=dQY9ZB/oKosM/KMasxehfbs9R1leeN9Rnj/69ofP5grVMxu5JaFdGvhJGRebuBZi7OGjHl bORMmviQBX2i/GzRw6x1pVZX0j6jsSzonQDNMBf10E8P23xmjjqrbJU3XutaZMJERcoEJG hxNLV9h1QpJL+qpNUbty2g9vLNtlTVw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-SPepYcByPpW8QgeLDj9gAw-1; Wed, 12 Oct 2022 02:50:59 -0400 X-MC-Unique: SPepYcByPpW8QgeLDj9gAw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 861038027EB for ; Wed, 12 Oct 2022 06:50:59 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2677FC23F71; Wed, 12 Oct 2022 06:50:55 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 29C6osTP412950 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 12 Oct 2022 08:50:54 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29C6ormh412949; Wed, 12 Oct 2022 08:50:53 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Disable tree to bool conversion in frange::update_nan. Date: Wed, 12 Oct 2022 08:50:48 +0200 Message-Id: <20221012065050.412900-3-aldyh@redhat.com> In-Reply-To: <20221012065050.412900-1-aldyh@redhat.com> References: <20221012065050.412900-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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