Program fails with debug off, works with it on?

BlitzMax Forums/BlitzMax Programming/Program fails with debug off, works with it on?

Okay. I am still hunting down the bug. What I've found now is even more bizarre. If I insert a couple of Print statements into the code, as below:

              Select MMode
                        Case 0          'Replace mode - Copies RGBA/XXYY solidly overwriting all data
                                If MSteep

Print MClipFast    'Prints a 0 (false) which is correct

                                        If MClipFast

Print "Shouldn't be here!: "+MClipFast    'Prints a 0 (which it is, but the IF shouldn't have been taken!)

                                                If MY>-1 And MY<MWidthFast And MX>-1 And MX<MHeightFast
                                                        (MBasePointer+MY+(MX*MRowBytes))[0]=MColorFast          'Replace at Y,X
                                                        MClipping=False         'Does the line start outside the bitmap?
                                                Else
                                                        MClipping=True          'The line starts outside the bitmap
                                                EndIf
                                        Else
                                                (MBasePointer+MY+(MX*MRowBytes))[0]=MColorFast          'Replace at Y,X
                                        EndIf
                                Else
 


What happens now is that the MClipFast variable is False or 0 .... which it should be, as passed to the function. However, the IF statement which is ONLY supposed to be performed if MClipFast is NONZERO, is actually taken.

If I change the code to: If MClipFast=False the If section is NOT taken, even though the MClipFast variable is clearly still a 0. It's supposed to be the other way around.

Again, this problem is fixed with Debug on, but persists without the debug version.

What's going on here? Is this a compiler bug? I can't really set the If to be the inverse of logic, because it wont work while I'm debugging, and similarly I can't set it to what it should be because it fails in the `release` version. So I'm stuck.

Any ideaS?