Bug 147758 - strange warning about alloca
Summary: strange warning about alloca
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 3
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-02-10 23:20 UTC by Sam Steingold
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version: 4.0.0-0.30
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-03-01 12:22:02 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2005:257 0 normal SHIPPED_LIVE gcc bug fix update 2005-06-09 04:00:00 UTC

Description Sam Steingold 2005-02-10 23:20:55 UTC
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
  objects

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

How reproducible:
Always

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

Actual Results:  warning

Expected Results:  no warning

Additional info:

see also
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19881>

Comment 1 Jakub Jelinek 2005-03-01 12:22:02 UTC
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 10:57:33 UTC
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.

http://rhn.redhat.com/errata/RHBA-2005-257.html



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