From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80643 invoked by alias); 4 Nov 2016 09:33:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 80519 invoked by uid 89); 4 Nov 2016 09:33:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Nov 2016 09:33:01 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C3813D953; Fri, 4 Nov 2016 09:33:00 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-19.brq.redhat.com [10.40.204.19]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA49WwqW019411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 4 Nov 2016 05:32:59 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id uA49WvFa028686; Fri, 4 Nov 2016 10:32:57 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id uA49Wtrt028680; Fri, 4 Nov 2016 10:32:55 +0100 Date: Fri, 04 Nov 2016 09:33:00 -0000 From: Jakub Jelinek To: Martin =?utf-8?B?TGnFoWth?= Cc: Marek Polacek , GCC Patches Subject: Re: [PATCH, RFC] Introduce -fsanitize=use-after-scope (v2) Message-ID: <20161104093254.GS3541@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20161027172358.GN3541@tucnak.redhat.com> <782727c2-9173-24ab-4e4c-07918dc16bf6@suse.cz> <20161101145350.GS3541@tucnak.redhat.com> <3f0181a4-e1b2-406f-7cf1-e63e9e9824fe@suse.cz> <20161102095926.GM3541@tucnak.redhat.com> <20161102101053.GN3541@tucnak.redhat.com> <20161102142028.GQ5939@redhat.com> <8ac49efe-83af-933b-2aa5-f4b22972fa6a@suse.cz> <20161102143511.GV3541@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00396.txt.bz2 Hi! On Fri, Nov 04, 2016 at 10:17:31AM +0100, Martin Liška wrote: > diff --git a/gcc/gimplify.c b/gcc/gimplify.c > index 813777d..86ce793 100644 > --- a/gcc/gimplify.c > +++ b/gcc/gimplify.c > @@ -1678,7 +1678,9 @@ warn_switch_unreachable_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, > worse location info. */ > if (gimple_try_eval (stmt) == NULL) > { > - wi->info = stmt; > + gimple_stmt_iterator *it = XNEW (gimple_stmt_iterator); > + memcpy (it, gsi_p, sizeof (gimple_stmt_iterator)); That would be cleaner as *it = *gsi_p; That set, I fail to see 1) the need to use a gsi pointer in wi->info compared to stmt itself, you can gsi_for_stmt cheaply at any time 2) why is anything done about this in warn_switch_unreachable_r - the problem isn't related to this warning IMHO. Even switch (x) { case 1: int x; x = 6; ptr = &x; break; case 2: ptr = &x; *ptr = 7; break; } has the same issue and there is no switch unreachable code there, but you still want for -fsanitize-use-after-scope pretend it is actually: x_tmp = x; { int x; switch (x_tmp) { case 1: x = 6; ptr = &x; break; case 2: ptr = &x; *ptr = 7; break; } } and put ASAN_MARK unpoisoning before GIMPLE_SWITCH. Jakub