From patchwork Fri Nov 14 19:20:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 410986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 55F241400AB for ; Sat, 15 Nov 2014 06:20:48 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=t0662hQjPLLA/Xb4Z Wb2p6XenTCpU8ElKz2ktj27Zwx5qneNKcUzTnWwosQULWg4JsnLc2+Cu5ntPkjZL 3jKGGi7Pf72zLxVgf30ptXbBWB3kbXYgsoQCjcbNaK27iQK4h13bZBSJy92/ds5i Sla1Lb/lA8XG49Tkowdg/b6FJI= 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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=NJFZhbeSQnuY1CoAG1jqJc/ oYJA=; b=AwBDawjASm4lwy3UiBSCxJdcD7F2m9zMWLHplm9XfUkhFItvYyt0764 WqUfbvGm5jT7shd2CUwkHLCt9MXpkLBMSWCyT6N0jXiOiJJLxiy8XIz01fNWEdV6 QlMVX/43kq5xQFNpTe5BzLrSDB3cXj0VX573p2CGkh4faycFydCA= Received: (qmail 31620 invoked by alias); 14 Nov 2014 19:20:40 -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 31600 invoked by uid 89); 14 Nov 2014 19:20:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Nov 2014 19:20:38 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1XpMQ7-0006Nx-65 from Cesar_Philippidis@mentor.com ; Fri, 14 Nov 2014 11:20:35 -0800 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.181.6; Fri, 14 Nov 2014 11:20:34 -0800 Message-ID: <54665600.3080209@mentor.com> Date: Fri, 14 Nov 2014 11:20:32 -0800 From: Cesar Philippidis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Janne Blomqvist , Fortran List , GCC Patches Subject: Re: [PATCH, libgfortran] PR 60324 Unbounded stack allocations in libgfortran References: In-Reply-To: On 11/13/2014 02:32 AM, Janne Blomqvist wrote: > in the spirit of PR 60324 and 61035, here's a patch that gets rid of > the remaining potentially unbounded stack allocations in libgfortran. > All uses of __builtin_alloca() and VLA's are replaced either straight > with heap allocated memory, or with a fixed size stack buffer, > potentially switching to heap storage for large sizes in places where > performance might matter. In order to avoid reintroducing these kinds > of issues, I also added -Werror=vla to AM_CFLAGS. > > This might also help limited targets like nvptx that lack VLA's. > > Regtested on x86_64-unknown-linux-gnu, Ok for trunk? I hit an error when building intrinsics/random.c: error: expression in static assertion is not constant Joseph told me that static const variables cannot be used in constant expressions in C, so I've replaced the _Static_assert with a regular assert. Are you using g++ to build libgfortran? I don't have a good baseline test this patch thoroughly, but at least I can bootstrap gcc without it failing in libgfortran. Is this OK for mainline and/or could someone see if it causes any regressions? Thanks, Cesar 2014-11-14 Cesar Philippidis libgfortran/ * intrinsics/random.c (random_seed_i4): Replace _Static_assert with assert. diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c index 5e91929..6b07a66d 100644 --- a/libgfortran/intrinsics/random.c +++ b/libgfortran/intrinsics/random.c @@ -25,6 +25,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #include "libgfortran.h" +#include #include #include @@ -669,8 +670,8 @@ random_seed_i4 (GFC_INTEGER_4 *size, gfc_array_i4 *put, gfc_array_i4 *get) #define KISS_MAX_SIZE 12 unsigned char seed[4 * KISS_MAX_SIZE]; - _Static_assert (kiss_size <= KISS_MAX_SIZE, - "kiss_size must <= KISS_MAX_SIZE"); + assert (kiss_size <= KISS_MAX_SIZE + && "kiss_size must <= KISS_MAX_SIZE"); __gthread_mutex_lock (&random_lock);