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];
Your goto
makes you skip the line that allocates apply
(at runtime).
You can solve the problem in one of four ways:
1: Rewrite your code so you don't use goto.
2: Move the declaration of apply
to before the goto
.
3: Change the scope so that error:
is outside the scope of apply
:
int test_alloc_stack(int size){
if(0) goto error; // same issue whatever conditional is used
{
int apply[size];
give_values(apply,size);
return 1;
}
error:
return 0;
}
4: Change the variable declaration so its size can be determined at compile-time.