by mlepage » Jan 21, 2004 @ 5:26am
The data is initialized. It is a vector of vector of int which is initialized to 4x8 all -1.
Rows 2 and 3 are supposed to always be -1, and they are before a few lines of code in a switch statement are executed. After the switch, a value becomes changed in those lines. The lines in the switch for that case are hardcoded to only touch rows 0 and 1. The other index (0 to 7) is not hardcoded but it is within range. There is a break in each case.
The data is only really touched there. So because my app is single threaded, and it is fine before the lines and not fine after, we know the problem is in those lines. And yet, visually checking the lines reveals no way it could cause the problem.
It happens only on release builds on the device. If I produce a build hardcoded to only take a particular path through the switch statement, one build for each case, they all work fine. If I add a print statement at the end of the case, it works fine.
This leads me to believe that the optimizer is doing something wacky when optimizing the switching statement. I will try other things such as changing it to an if-else statement.
In my experience, optimizer bugs are like this. I had a lot on the DEC Alpha compiler, eventually we had to just disable the optimizer as it was too flaky.