In the following case the optimizer seems to assume, that the array does
not change during the loop and optimizes away the sizeof check:
int main() {
array a = ({ 1, 2, 3, 4, 5 });
void magic(int k) {
a = a[0..k-1] + a[k+1..];
};
for (int i = 0; i < sizeof(a); i++) {
if (a[i] == 2) {
magic(i);
i--;
}
}
return 0;
}
I assume cases like this are hard to detect, especially because
this can me made even more complicated. I will put in some
if (0) { ret = ({});}
equivalent to trick the optimizer for now.
arne