This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/38957] New: [4.3/4.4 Regression] return of local variable pointer
- From: "tkoenig at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jan 2009 11:24:26 -0000
- Subject: [Bug c/38957] New: [4.3/4.4 Regression] return of local variable pointer
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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