A bug appears to be present in the ppc/mb compiler.
In some cases, your coding style may affect the compiler results. The "volatile" keyword is an important concept in embedded programming.
Most compilers optimize the code by assuming that a value stays in the memory unless the program changes it. General compilers feature this optimization for better performance. In embedded system applications, this may cause a problem in the shared-data code and I/O access. Make sure that you use the "volatile" keyword in the variable declaration (the "volatile" keyword is part of the C standard.) This keyword specifies to the compiler that the microprocessor must read the value from the memory location (or memory-mapped location) every time it is referenced.