Roy
With the debugger attached in each case, let the code run a sort time and pause. Then just look at the register view of the modules to see the differences.
If optimisation is causing problems you must have code that requires volatile definitions to ensure correct operation.
Although the tradition is to develop in debug mode and release in release mode this is not necessary a very wise strategy - I think that experienced developers will always work in release mode in order to find problems at the start of project rather at the end. It also means that all the development and testing that has been done in debug mode may be pointless in the release mode behaves differently (lots of effort down the drain). With a little practice it is not much harder to debug (even with GCC) in release mode and then you are continuously testing the final version all the time.
Regards
Mark