From patchwork Mon Oct 25 18:27:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 46640 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FEDB385742F for ; Mon, 25 Oct 2021 18:28:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 26746385743E; Mon, 25 Oct 2021 18:27:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 26746385743E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: NzIsjwI3krPynf8pBlYl1qJRRZLQLMablHiwmzYmvckBYsUMQGcwtm/xbQ444AyjvLq35Xsrdh K63OXitzD0MclcE4ffprAEVCStYcWFkDVZDit2242MCdb75rClERJ8LpwuztdQGBo/2nPiC4On Yfv7NWYtueUGdJUhwfx7cyw61hM5YTZwoTNMQrXH0p2YHdSbsYUirOi09cMBbT2RVaR3eB+TKw tiyqLJfCcTogCN82N+BAL82BwSrRMd6lCHpTsdAdPqdbLIF7btqr3LGDJy57+bN8LQOOZ6/3k/ Q084GV0Ed8ALE/Mr1yHkIQ51 X-IronPort-AV: E=Sophos;i="5.87,181,1631606400"; d="scan'208";a="70082221" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 25 Oct 2021 10:27:25 -0800 IronPort-SDR: 4qCk1V5i3q2q52ad06cspZwXyQhV7LmKolI7q8gZDIWKwS1/eUy8nnlX36R8Naiiwui+joFKL5 8D4+uGeW2NLCRKqNJG5x+J59ITujblbNZEFdrshVCh12R3jvmF78ZtLu1xCDd2ZA/Ullr7parc hSmJ8KvjfJs0ZJl+R5t+zB68YMorDwHPEf5veb+Wsfq1r+TCg7SYm21v6oCfxzxaZGis143sVU 8fft4Yb7ZrQnnzRSIKybIr0kUqv2JkVIufc4uIs7mdOJefDSAOc4oCCsD+tNFr1wMFozAvduOZ 1Vo= To: "gcc-patches@gcc.gnu.org" , "fortran@gcc.gnu.org" From: Sandra Loosemore Subject: [Fortran] Fix broken use of alloca in C interoperability testcase Message-ID: <242ab49c-5047-c7fe-ee06-23210f3bbe18@codesourcery.com> Date: Mon, 25 Oct 2021 12:27:18 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 Content-Language: en-US X-ClientProxiedBy: SVR-ORW-MBX-06.mgc.mentorg.com (147.34.90.206) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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: , Cc: sgk@troutmask.apl.washington.edu Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch is for PR102910. There's no reason why the testcase in question needs to use alloca, but I wasn't aware there were portability issues with it until I saw this issue. I think this fix is probably obvious and will commit it tomorrow unless I get some feedback on it meanwhile. -Sandra commit 75b603334401d079391ca950dd2e22663cdb3080 Author: Sandra Loosemore Date: Mon Oct 25 11:08:28 2021 -0700 [Fortran] Fix broken use of alloca in C interoperability testcase 2021-10-25 Sandra Loosemore gcc/testsuite/ PR testsuite/102910 * gfortran.dg/c-interop/cf-descriptor-5-c.c: Use a static buffer instead of alloca. diff --git a/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c b/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c index 12464b5..320a354 100644 --- a/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c +++ b/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c @@ -1,6 +1,5 @@ #include #include -#include #include #include "dump-descriptors.h" @@ -8,12 +7,18 @@ extern void ctest (int n); extern void ftest (CFI_cdesc_t *a, int n); +#define BUFSIZE 512 +static char adata[BUFSIZE]; + void ctest (int n) { CFI_CDESC_T(0) adesc; CFI_cdesc_t *a = (CFI_cdesc_t *) &adesc; - char *adata = (char *) alloca (n); + + /* Use a fixed-size static buffer instead of allocating one dynamically. */ + if (n > BUFSIZE) + abort (); /* Fill in adesc. */ check_CFI_status ("CFI_establish",