In the following case the optimizer seems to assume, that the array does not change during the loop and optimizes away the sizeof check:
[...]
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.
I guess it would be possible to check if any of the variables in the expression are in min_number_of_locals (cf program.c:pop_local_variables()), but I believe the problem is quite rare.
arne