Bug 147758 - strange warning about alloca
strange warning about alloca
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2005-02-10 18:20 EST by Sam Steingold
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: 4.0.0-0.30
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-03-01 07:22:02 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Sam Steingold 2005-02-10 18:20:55 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Description of problem:
================================= foo.c ============================
#include <alloca.h>
#include <string.h>
#include <stdlib.h>

extern void bar (char*, char*);

void foo (const char *name, const char *type)
    size_t name_len = strlen (name);
    char *name_temp = (char *) alloca (name_len);
    if (name_len > 0)
      memcpy (name_temp, name, name_len);
      char name_copy[name_len + 2];
      memcpy (name_copy, name_temp, name_len);
      name_copy[name_len] = '$';
      name_copy[name_len + 1] = '\0';
        size_t type_len = strlen (type);
        char *type_temp = (char *) alloca (type_len);
        if (type_len > 0)
          memcpy (type_temp, type, type_len);
          char type_copy[type_len + 2];
          memcpy (type_copy, type_temp, type_len);
          type_copy[type_len] = '$';
          type_copy[type_len + 1] = '\0';
            bar (name_copy, type_copy);
================================= foo.c ============================
produces this warning:
$ gcc -c foo.c
foo.c: In function `foo':
foo.c:21: warning: alloca()ed storage released along with dynamically-sized auto

Version-Release number of selected component (if applicable):
gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)

How reproducible:

Steps to Reproduce:
1.save file foo.c
2.gcc -c foo.c

Actual Results:  warning

Expected Results:  no warning

Additional info:

see also
Comment 1 Jakub Jelinek 2005-03-01 07:22:02 EST
I have reverted the alloca warning patch for now in gcc-3.4.3-21.
gcc-4.0.0-0.30 ATM in rawhide never had this patch in.
Comment 2 Tim Powers 2005-06-09 06:57:33 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.