According to this answer, which states:
The compiler knows the size of the int type and therefore can generate the right assembler instruction that will reserve enough space on the stack in order to let foo live there.
a compiler needs to know the size a function will occupy on the stack in order to implement it.
Then, why does this code compile?
int f(int n)
{
int x[n];
}
int main()
{
f(3);
f(5);
//etc
}
x
is an array of integers, but its size isn't constant, it can change any time the function is called.
What am I missing here?