3 ms·
> more machinery is necessary to track those dependencies. Well, is it much more machinery? IIRC doing void f(size_t n) { int x[n]; n += 1
by Joker_vD 3y ago
> more machinery is necessary to track those dependencies.
Well, is it much more machinery? IIRC doing
void f(size_t n) {
int x[n];
n += 1;
...
does not resize x, so there is no dataflow dependency or rather, x depends on a hidden const variable so no additional dataflow analysis necessary.
- LegionMammal978 3y agoYet 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()".