From patchwork Wed Jul 21 23:25:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1508496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: 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=yF0kBq0o; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GVWt41Tx8z9sV8 for ; Thu, 22 Jul 2021 09:26:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BAE983943413 for ; Wed, 21 Jul 2021 23:25:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAE983943413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1626909959; bh=g37FU7Pf8Fysr8epmhLC6q9ANk44jhLFEQDRbQleRDo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yF0kBq0odkDCLS0IWU0LzFhcsgUeY/mbGt/dyUqLakIp/O4Yzp91dGbyjP4SETHTG Zm7bTIFbN+jYEjsSLPPcIV6V38eGg0XibNgKSnrT5tqhOnixeXa16hT95LN634q4zI LSLTc90WTvsZACRId/RHNhYBk+fyadg9JjcSyE8k= 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.133.124]) by sourceware.org (Postfix) with ESMTP id DB5323938399 for ; Wed, 21 Jul 2021 23:25:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB5323938399 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-2SxV3YF1Oqu7sI6dD7yOQQ-1; Wed, 21 Jul 2021 19:25:19 -0400 X-MC-Unique: 2SxV3YF1Oqu7sI6dD7yOQQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 834A5802920 for ; Wed, 21 Jul 2021 23:25:18 +0000 (UTC) Received: from t14s.localdomain.com (ovpn-112-158.phx2.redhat.com [10.3.112.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 256A21002D71; Wed, 21 Jul 2021 23:25:17 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer: fix ICE in binding_cluster::purge_state_involving [PR101522] Date: Wed, 21 Jul 2021 19:25:15 -0400 Message-Id: <20210721232515.459947-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-2459-g87bd75cd49aac68e90bd9b6b5e14582d6e0ccafa. gcc/analyzer/ChangeLog: PR analyzer/101522 * store.cc (binding_cluster::purge_state_involving): Don't change m_map whilst iterating through it. gcc/testsuite/ChangeLog: PR analyzer/101522 * g++.dg/analyzer/pr101522.C: New test. Signed-off-by: David Malcolm --- gcc/analyzer/store.cc | 14 +++++++---- gcc/testsuite/g++.dg/analyzer/pr101522.C | 31 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/analyzer/pr101522.C diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index 0042a207ba6..8ee414da5c8 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -1323,6 +1323,7 @@ binding_cluster::purge_state_involving (const svalue *sval, region_model_manager *sval_mgr) { auto_vec to_remove; + auto_vec > to_make_unknown; for (auto iter : m_map) { const binding_key *iter_key = iter.first; @@ -1335,17 +1336,20 @@ binding_cluster::purge_state_involving (const svalue *sval, } const svalue *iter_sval = iter.second; if (iter_sval->involves_p (sval)) - { - const svalue *new_sval - = sval_mgr->get_or_create_unknown_svalue (iter_sval->get_type ()); - m_map.put (iter_key, new_sval); - } + to_make_unknown.safe_push (std::make_pair(iter_key, + iter_sval->get_type ())); } for (auto iter : to_remove) { m_map.remove (iter); m_touched = true; } + for (auto iter : to_make_unknown) + { + const svalue *new_sval + = sval_mgr->get_or_create_unknown_svalue (iter.second); + m_map.put (iter.first, new_sval); + } } /* Get any SVAL bound to REG within this cluster via kind KIND, diff --git a/gcc/testsuite/g++.dg/analyzer/pr101522.C b/gcc/testsuite/g++.dg/analyzer/pr101522.C new file mode 100644 index 00000000000..634a2ac30cd --- /dev/null +++ b/gcc/testsuite/g++.dg/analyzer/pr101522.C @@ -0,0 +1,31 @@ +// { dg-do compile { target c++11 } } + +double +sqrt (); + +namespace std { + class gamma_distribution { + public: + gamma_distribution () : _M_param () {} + + private: + struct param_type { + param_type () : _M_beta () { _M_a2 = 1 / ::sqrt (); } + double _M_beta, _M_a2; + }; + param_type _M_param; + int _M_saved_available, _M_saved = 0, _M_param0 = 0; + }; + + struct fisher_f_distribution { + gamma_distribution _M_gd_x, _M_gd_y; + }; +} + +int +main () +{ + std::fisher_f_distribution d; + + return 0; +}