public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4714] Fix broken use of alloca in C interoperability testcase
Date: Tue, 26 Oct 2021 14:25:10 +0000 (GMT)	[thread overview]
Message-ID: <20211026142510.8C1083858410@sourceware.org> (raw)

https://gcc.gnu.org/g:f9190a1c6d001099d1409298ae3b684499bd1fdd

commit r12-4714-gf9190a1c6d001099d1409298ae3b684499bd1fdd
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Mon Oct 25 11:08:28 2021 -0700

    Fix broken use of alloca in C interoperability testcase
    
    2021-10-25  Sandra Loosemore  <sandra@codesourcery.com>
    
            gcc/testsuite/
    
            PR testsuite/102910
            * gfortran.dg/c-interop/cf-descriptor-5-c.c: Use a static buffer
            instead of alloca.

Diff:
---
 gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

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 12464b55512..320a354730b 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 <stdlib.h>
 #include <stdio.h>
-#include <alloca.h>
 
 #include <ISO_Fortran_binding.h>
 #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",


                 reply	other threads:[~2021-10-26 14:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211026142510.8C1083858410@sourceware.org \
    --to=sandra@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).