On 5/12/2013 5:00 PM, Manu wrote:It's a form of "data flow analysis". This is done by the optimizer, although it doesn't track ranges.
So, here's an issue that constantly drives me nuts, and an elegant solution
seems so do-able.
It isn't quite as simple as you suggest, there are issues like dealing with arbitrary control flow.Ok, but what about:
x &= 0xFFFF;
short s = x; // Error! (but we know x is 0 .. 65535)
x &= 0xFFFF;
while (expr) {
short s = x;
x += 1;
}
There's a forward reference going on. We cannot semantically evaluate s=x until we semantically evaluate the rest of the function in order to know that x is or is not reassigned.