3 ms·
I probably should have made the second conditional `(x < 2)` rather than `(x < 4)` so that the compiler should not generate a warning. Here a serious compiler w
by mnarayan01 10y ago
I probably should have made the second conditional `(x < 2)` rather than `(x < 4)` so that the compiler should not generate a warning. Here a serious compiler would likely be able to statically determine that the variable was always initialized, but for a sufficiently complex function call (even an inlined one) it would not.
The compiler could just be "conservative" like you said and warn whenever it couldn't statically determine validity, but note that initializing e.g. `y = 0` has a performance cost (cf. reordering constructor initializers).