I found that this refuses to compile :
int test_alloc_stack(int size){
if(0) goto error; // same issue whatever conditional is used
int apply[size];
It is forbidden by the standard:
C99 standard, paragraph 6.8.6.1
Constraints
[...] A goto statement shall not jump from outside the scope of an identifier having a variably modified type to inside the scope of that identifier.
Which is exactly what your goto is doing, namely, jumping from outside the scope of apply to inside it.
You can use the following workaround to limit the scope of apply:
if(0) goto error;
{
int apply[size];
give_values(apply,size);
return 1;
}
error:
return 0;