From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19093 invoked by alias); 31 Oct 2013 01:10:36 -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 19074 invoked by uid 89); 31 Oct 2013 01:10:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 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; Thu, 31 Oct 2013 01:10:34 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9V1AW1R020993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Oct 2013 21:10:32 -0400 Received: from [10.10.116.17] ([10.10.116.17]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9V1AUqA026943; Wed, 30 Oct 2013 21:10:31 -0400 Message-ID: <5271AE06.9020004@redhat.com> Date: Thu, 31 Oct 2013 03:18:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Marek Polacek CC: GCC Patches , Jakub Jelinek , "Joseph S. Myers" Subject: Re: [PATCH][ubsan] Add VLA bound instrumentation References: <20130912122655.GN23899@redhat.com> <20130925124132.GJ12296@redhat.com> <52697B9D.9000502@redhat.com> <20131025165803.GF27400@redhat.com> <526AB5CC.60408@redhat.com> <20131025190356.GG27400@redhat.com> <526AC0C9.1050003@redhat.com> <20131030145253.GB31396@redhat.com> <52712C29.3010206@redhat.com> <20131030161504.GC31396@redhat.com> In-Reply-To: <20131030161504.GC31396@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2013-10/txt/msg02643.txt.bz2 On 10/30/2013 12:15 PM, Marek Polacek wrote: > On Wed, Oct 30, 2013 at 11:56:25AM -0400, Jason Merrill wrote: >> Saving 'size' here doesn't help since it's already been used above. >> Could you use itype instead of size here? > > I already experimented with that and I think I can't, since we call > the finish_expr_stmt too soon, which results in: > > int x = 1; > int a[0:(sizetype) SAVE_EXPR ]; > > <>; > < if (SAVE_EXPR <= 0) > { > __builtin___ubsan_handle_vla_bound_not_positive (&*.Lubsan_data0, (unsigned long) SAVE_EXPR ); > } > else > { > 0 > }, (void) SAVE_EXPR ; >>>>>; > ssizetype D.2143; > < (void) (D.2143 = (ssizetype) ++x + -1) >>>>>; Ah, looks like you're getting an unfortunate interaction with stabilize_vla_size, which is replacing the contents of the SAVE_EXPR with a reference to a variable that isn't initialized yet. Perhaps we should move the stabilize_vla_size call into compute_array_index_type, too. > and that ICEs in gimplify_var_or_parm_decl, presumably because the > if (SAVE_EXPR <= 0) { ... } should be emitted *after* that > cleanup_point. When we generated the C++1y check in cp_finish_decl, > we emitted the check after the cleanup_point, and everything was OK. > I admit I don't understand the cleanup_points very much and I don't > know exactly where they are coming from, because normally I don't see > them coming out of C FE. :) You can ignore the cleanup_points; they just wrap every full-expression. Jason