[parisc-linux] Re: Looking at vfprintf.c and alloca.
John David Anglin
dave at hiauly1.hia.nrc.ca
Tue Jul 18 20:48:47 MDT 2006
> I tried this with both old (gcc-3.[34]) and new gcc (gcc-4.[01]) and i
> don't think this works....
>
> tausq at riot:~$ cat alloca.c
> #include <alloca.h>
> #include <stdio.h>
>
> int main(int argc, char **argv)
> {
> int *old;
> int *ptr = alloca(100 * sizeof(int));
>
> old = ptr;
>
> ptr = alloca(100 * sizeof(int));
>
> printf("ptr = %p\nold = %p\n&old[100] = %p\n", ptr, old,
> &old[100]);
> return 0;
> }
> tausq at riot:~$ gcc-4.1 -Wall -o alloca alloca.c; ./alloca
> ptr = 0xc04ca590
> old = 0xc04ca3d0
> &old[100] = 0xc04ca560
What doesn't work? ptr - old = 0x1c0 = 7 * 64. The preferred
stack boundary is 64 bytes. 6 * 64 = 384 bytes. That's too
small for the requested allocation. &old[100] - old = 0x190 = 400.
So, the results printed appear correct.
Dave
--
J. David Anglin dave.anglin at nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
More information about the parisc-linux
mailing list