I have some straightforward code that fails when Level 1 optimization
(Faster Execution) is turned on.

Here is the code:

    char *pThisDescriptor =
GetDescriptor(CPreferences::GetDescriptorFilterType());

    // macy debug
    char *pTest = CPreferences::GetDescriptorFilter();
  int Test = StrCompare(pThisDescriptor,
CPreferences::GetDescriptorFilter());
  // end macy debug

// THIS NEXT LINE IS SKIPPED WHEN OPTIMIZATION IS ON
    if(0 == StrCompare(pThisDescriptor,
CPreferences::GetDescriptorFilter()))
        return(TRUE);

    return(FALSE);

------------------------------

When optimization is on, that StrCompare line is eliminated (can't set
breakpoint there), and the return(TRUE) statement is always executed.  With
optimization off, it works fine.  CPreferences::GetDescriptorFilter()
returns a pointer to a static variable.  I've confirmed that the StrCompare
function can return a result other than 0.

Could be that I missed something here, but this part of my application works
when optimization is turned off, and fails when it is turned on.

Should we not trust the optimization?

Using Codewarrior 4.0.1, build 0436 on Win 2000.



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to