F
Franz Hose
the following program, when compiled with gcc and '-std=c99', gcc says
test.c:6: error: jump into scope of identifier with
variably modified type
that is, it does not even compile.
lcc-win32, on the other hand, reports
Warning test.c: 7 unreachable code
the resulting program crashes at runtime, but I guess that can be
expected because x is probably uninitialized (UB?)
My question is, is the below program invalid or is undefined
behaviour invoked?
--------------------------------------------------
#include <stdio.h>
void func1(int n)
{
goto label;
int x[n];
label:
x[0] = 42;
printf("x[0] = %d\n", x[0]);
}
int main(void)
{
func1(5);
return 0;
}
--------------------------------------------------
test.c:6: error: jump into scope of identifier with
variably modified type
that is, it does not even compile.
lcc-win32, on the other hand, reports
Warning test.c: 7 unreachable code
the resulting program crashes at runtime, but I guess that can be
expected because x is probably uninitialized (UB?)
My question is, is the below program invalid or is undefined
behaviour invoked?
--------------------------------------------------
#include <stdio.h>
void func1(int n)
{
goto label;
int x[n];
label:
x[0] = 42;
printf("x[0] = %d\n", x[0]);
}
int main(void)
{
func1(5);
return 0;
}
--------------------------------------------------