Palm developers,
We have found an optimizer bug in CodeWarrior for Palm OS 7 that causes a
serious problem in the DateDB.c code from Palm OS 3.5. The bug causes the
ApptComparePackedRecords routine to return incorrect results, resulting in
mis-sorting of the DatebookDB. The bug occurs at optimization levels >= 2,
but goes away at levels 0 and 1.
We found the bug when investigating a customer bug report for Life Balance
2.5. Life Balance uses DateDB.c to manipulate the Palm's built-in Date Book
records. The bug would affect any application that compiles DateDB.c using
the new version of CodeWarrior.
You can eliminate the bug by wrapping the following code around the
definition of ApptComparePackedRecords in DateDB.c:
// These pragmas work around an optimizer bug in the Metrowerks CodeWarrior
// MW C/C++ 68K compiler version 2.4.1 build 0133, which comes with CW for
// Palm OS 7. The same bug is present in version 2.4 build 0131, which
// comes with CW Pro 6. The bug affects certain cases of boolean logic
// using bitfields.
// Once Metrowerks releases a corrected compiler plugin, the version test
// can be changed to (__MWERKS__ >= 0x2400) && (__MWERKS__ < 0x????).
#ifdef __MWERKS__
#if __MWERKS__ >= 0x2400
#pragma push
#pragma defer_codegen off
#pragma optimization_level 1
#endif
#endif
[Definition of ApptComparePackedRecords goes here.]
// This pragma closes the optimizer bug fix above.
#ifdef __MWERKS__
#if __MWERKS__ >= 0x2400
#pragma pop
#endif
#endif
So far this is the only function we've seen that triggers the bug in
Codewarrior, but you may want to keep an eye out in your own code for
similar boolean arithmetic on bitfields.
We've reported the problem to Metrowerks.
--Stuart A. Malone & Catherine E. White
Llamagraphics, Inc.
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/