gcc accumulates instead of overlaying frame variables
Michael LeBlanc
leblanc@skycomputers.com
Thu May 13 09:29:00 GMT 2004
I am submitting this as instructed, as a last resort, because
(1) I can't figure out how to attach files in the bugzilla page; and
(2) I can't find a gccbug script in a 3.3 source package.
So here are the things from
gcc -v -save-temps x.c f.c
$ tar tvf gnu.tar
drwxrwxr-x leblanc/leblanc 0 2004-05-12 12:50:24 ./
-rw-rw-r-- leblanc/leblanc 152 2004-05-12 12:12:33 ./x.c
-rw-rw-r-- leblanc/leblanc 76 2004-05-12 12:10:54 ./f.c
-rw-rw-r-- leblanc/leblanc 207 2004-05-12 12:49:20 ./x.i
-rw-rw-r-- leblanc/leblanc 367 2004-05-12 12:49:20 ./x.s
-rw-rw-r-- leblanc/leblanc 134 2004-05-12 12:49:20 ./f.i
-rw-rw-r-- leblanc/leblanc 437 2004-05-12 12:49:20 ./f.s
-rw-rw-r-- leblanc/leblanc 2776 2004-05-12 12:49:20 ./stderr
See the source down below. SUN and Metaware believe, correctly, that
the
two blocks overlay each other in the final stack frame. GCC adds them
together. It looks like this mistake has been around for quite a while.
(1) on Solaris
SUN
% /opt/SUNWspro/bin/cc -V
cc: Sun WorkShop 6 2000/04/07 C 5.1
% /opt/SUNWspro/bin/cc x.c f.c
x.c:
f.c:
% ./a.out
frame is about 612 bytes
frame is about 612 bytes
HighC
% hc x.c f.c -Hcopyr
x.c:
MetaWare High C Compiler R2.8 Serial 1-SKY-799999.
(c) Copyright 1987-98, MetaWare Incorporated
f.c:
w "f.c",L4/C3(#291): printf: Function called but not
declared.
No errors 1 warning
% ./a.out
frame is about 608 bytes
frame is about 608 bytes
GCC
% gcc -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/specs
gcc version 2.95.3 20010315 (release)
% gcc x.c f.c
% ./a.out
frame is about 1136 bytes
frame is about 624 bytes
(2) on YDL 3.0
$ gcc -v
...
gcc version 3.3
$ gcc x.c f.c
$ ./a.out
frame is about 547 bytes
frame is about 1059 bytes
SOURCE
% cat f.c
void foo(char *p)
{
char x;
printf("frame is about %d bytes\n",p-&x);
}
% cat x.c
#define N 512
extern void foo(char *p);
int main()
{
{
char x[N];
foo(&x[N-1]);
}
{
char x[N];
foo(&x[N-1]);
}
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnu.tar
Type: application/x-tar
Size: 20480 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20040513/c403a04e/attachment.tar>
More information about the Gcc-bugs
mailing list