4 ms·
Yet void f(size_t n, int cond) { if (cond) { n += 1; } int x[n]; ... does resize x depending on the value of cond, so the size can't neces
by LegionMammal978 3y ago
Yet
void f(size_t n, int cond) {
if (cond) { n += 1; }
int x[n];
...
does resize x depending on the value of cond, so the size can't necessarily be known until the point where the type (int[n] in this case) is named.
Also, the compiler has to make sure it keeps around implicit locals to store the variable layouts, so that code like
void f(size_t n) {
typedef int array[n];
n += 1;
array x;
...
functions as specified. This kind of pattern is one of the bigger things setting the feature apart from just "syntax sugar for alloca()".