Hi,

I'm sure I've run into this before, but can't remember what the
problem was.  The symptom is that the optimiser is removing 
code I consider valid, leaving certain logic non-functional.

Essentially I have a function that tests a variety of conditions, 
setting a flag to false if any condition fails.  The function then
ends with the following lines:

 if (TestsOK)
 {
  return errNone;
  
 } else
 {
  return gInfo.ErrorCode;
 }

My problem is that with dead code elimination on, the test is 
ignored and errNone is returned regardless of the state of the
TestsOK variable (which *is* false when this function exits).

Leaving aside any style issues for the moment :-), can anyone 
suggest why this is happening?  The code to set the flag to true 
and false in different places seems to be compiling in (although 
I haven't checked the assembler yet) the compiler simply seems 
to consider the if statement to be dead code.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to