[Bug c/38957] New: [4.3/4.4 Regression] return of local variable pointer

tkoenig at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Jan 24 11:24:00 GMT 2009


4.3 and 4.4 don't catch the pointer expression pointing
to a local variable:

$ cat foo.c
char *foo(void)
{
    char a[2];
    return a+1;
}

char *bar(void)
{
    char a[2];
    return a;
}
$ gcc-4.2 -S -Wall -Wextra -O3 foo.c
foo.c: In function 'foo':
foo.c:4: warning: function returns address of local variable
foo.c: In function 'bar':
foo.c:10: warning: function returns address of local variable
$ gcc-4.3 -S -Wall -Wextra -O3 foo.c
foo.c: In function 'bar':
foo.c:10: warning: function returns address of local variable
$ gcc -S -Wall -Wextra -O3 foo.c
foo.c: In function 'bar':
foo.c:10: warning: function returns address of local variable


-- 
           Summary: [4.3/4.4 Regression] return of local variable pointer
           Product: gcc
           Version: 4.3.4
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38957



More information about the Gcc-bugs mailing list