Hello everyone,
First of all, before I begin, I am using VC++ 2008 professional, running an Intel core2 on windows OS. I also know that this code will NEVER be executed on anything other than a core2/corei7 running Windows.
I have a while loop with 2 conditions that looks something like this: note: this is a much simplified version.
while((a != b) && (array[a] < c))
If the first condition (a != b)
generates a false, will the second condition even be evaluated? or will the loop just terminate right there?
I did a few tests and it seems that it is indeed true.
However, here is the catch. When and if first condition evaluates false, the second condition WILL generate an access violation if it is evaluated. However, from what i can see, once the first condition is evaluated as false, the program doesn't bother to evaluate the second condition and quits the loop, thus saving me.
The problem is that I can't quite get rid of the access violation problem without making my very nice and neat code suddenly blow up on me. However, due to the little "bug" (i know it's a compiler optimization, not a bug), I seem to be able to get away from it. I also know this is probably not good programming practice to do, but to be honest, in my situation, if it works, I'm already ahead of the game.
My question is, will this "bug" or programming malpractice come back and bite me some day? Even when considering that I tested the hell out of this section and WILL ONLY EVER USE IT THIS ONE TIME?