According to this answer , which says:
The compiler knows the size of type int and therefore can generate the correct assembler instruction, which will reserve enough space on the stack to allow foo to live there.
the compiler must know the size that the function will occupy on the stack in order to implement it.
Then, why is this code compiled?
int f(int n)
{
int x[n];
}
int main()
{
f(3);
f(5);
}
x is an array of integers, but its size is not constant, it can change at any time when the function is called.
What am I missing here?
source
share