From patchwork Thu May 23 10:51:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1104001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-501526-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ezOtTqsT"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 458mX31fLHz9s5c for ; Thu, 23 May 2019 20:51:29 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=LYWQJflmTVYkYo5Irxj53RvZH9QBmaT7CP6FCfGeyv8hnRn4kUvIV JuMgcyIsVXWyzSykszonqk8qIDwKmA/hyDoDuUE9qurzfxuvsRJI5v22R0DUvvr8 IlwZ0pmcuYewndGixP8DZaUIpJjH3Zc4+uuBl8rcpDekmzoBm4KZ5U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=oODYG8Hz5+WJ/568wRi+Iy4WcCw=; b=ezOtTqsTigWj+ByiYh4/ MbHkOErLHfqLVPwOEufORtMiTeGX7XEKy/2c4pMO1fHBQMEiF4i9cbVOaX93ZtUJ mFFPJb4sv/UvAPxbwSJ6tBAI2ai6xeQBobF50hBIun3zEYiUobFs2IMslh60jGnE LfRw61YwEOzu9nqQGB3nZ7Y= Received: (qmail 7582 invoked by alias); 23 May 2019 10:51:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7464 invoked by uid 89); 23 May 2019 10:51:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=bit_and_expr, BIT_AND_EXPR, to_wide X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 May 2019 10:51:21 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1C18DAF10 for ; Thu, 23 May 2019 10:51:19 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Do not use tree_to_wide_ref that point to a temporary (PR c++/90587). To: gcc-patches@gcc.gnu.org Message-ID: Date: Thu, 23 May 2019 12:51:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi. The PR is about use-after-scope issue where: wi::tree_to_wide_ref andw = wi::to_wide (val) & wi::to_wide (boundary); The RHS1 and RHS2 will become out-of-scope after operator& returns a reference. andw.val then points to one of RHS1 or RHS2. So that we end up with an use-after-scope. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: 2019-05-23 Martin Liska PR c++/90587. * tree-ssa-uninit.c (value_sat_pred_p): The result of & operation points to a temporary (pointed via tree_to_wide_ref) that is out of scope after the &. --- gcc/tree-ssa-uninit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index bc07afe32c8..fe8f8f0bc28 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -1058,7 +1058,7 @@ value_sat_pred_p (tree val, tree boundary, enum tree_code cmpc, if (cmpc != BIT_AND_EXPR) return is_value_included_in (val, boundary, cmpc); - wi::tree_to_wide_ref andw = wi::to_wide (val) & wi::to_wide (boundary); + wide_int andw = wi::to_wide (val) & wi::to_wide (boundary); if (exact_p) return andw == wi::to_wide (val); else