From patchwork Wed Oct 12 06:50:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1689049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=CEcO2Jdq; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MnNbb5w1xz23k4 for ; Wed, 12 Oct 2022 17:51:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DACBA38515D0 for ; Wed, 12 Oct 2022 06:51:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DACBA38515D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665557480; bh=j5q4Xau6O6CMqm1WqltjGxdNWkAKOS1jlxQtD3MkTpk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=CEcO2JdqavqnIjnlx8MQviAOkXWgTwNECSfLqu3EKAikEZ/cv1aoZ9i+tjlf9Mo2X IKuQicOkAIZNm0KEV0lh+KP0K0dytl19wL1b4XJ7YOdwtH4SDpt4ynOYU+f4TYG+v1 CXqogTsW8hSgO1XHeFWOJ48OcXZWOylemo9JMrWk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 To: GCC patches 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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