See this test program:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
if (argc < 2)
goto end;
char s[strlen(argv[1]) + 1];
strcpy(s, argv[1]);
printf("s=%s\n", s);
end:
return 0;
}
It fails to compile with the error "jump into scope of identifier with variably modified type" (see other question).
However it compiles fine if I change the declaration of s into this (and include alloca.h):
char *s = alloca(strlen(argv[1]) + 1);
Why does the C standard allow jumping into the scope of an object created with alloca, but not a variable length array? I thought they were equivalent.