alloca in function arguments (2.95.2)
llewelly@dbritsch.dsl.xmission.com
llewelly@dbritsch.dsl.xmission.com
Sun Apr 9 14:19:00 GMT 2000
On Sun, 9 Apr 2000, Alexander V. Lukyanov wrote:
> The following program does not produce the expected result.
> Maybe this is a bug, maybe an alloca limitation. If it is
> a limitation, a warning/error would be nice.
>
> system: gcc-2.95.2, linux-i686, glibc-2.1.3.
>
> #include <string.h>
> #include <stdio.h>
>
> void a(void *x,int y)
> {
> printf("y=%d\n",y);
> }
>
> int main()
> {
> a(strcpy(alloca(100),"abc"),1234);
> return 0;
> }
>
> Alexander.
>
>From the glibc-2.1 docs (type 'info alloca'):
# Do not use `alloca' inside the arguments of a function call--you
# will get unpredictable results, because the stack space for the
# `alloca' would appear on the stack in the middle of the space for the
# function arguments. An example of what to avoid is `foo (x, alloca
# (4), y)'.
More information about the Gcc-bugs
mailing list