Dynamic indexes
function curve_value(i) {
if(i < 0) i = 0;
if(i >= sizeof(CURVE)) i = sizeof(CURVE) - 1;
return CURVE[i];
}Last updated
The compiler can reject a constant out-of-range index. It cannot prove every runtime path:
function curve_value(i) {
if(i < 0) i = 0;
if(i >= sizeof(CURVE)) i = sizeof(CURVE) - 1;
return CURVE[i];
}When an index expression includes a function call, store the result first. The compiler can warn that a dynamic index call might be evaluated twice.
Last updated

