Here (build settings) -
I turned off Arm GCC/Compiler/Optimization/Optimization Level. This seemed to fix the problem. Here are my results with the settings,
None: Enters the if statement correctly
Debug: Enters into if statement even if conditions are not true
Minimal: Enters into if statement even if conditions are not true
High: Does not enter into statement, break points give an error
Speed: Does not enter into statement, break points give an error
Size: Does not enter into statement, break points give an error
See attached project. I have not run into this before - seems strange for a project so simple, I swear I have had similar projects before... Can someone explain why one kind does not allow me to enter into an if statement, and other kinds do it even when they should not?
My experiences with single-stepping are quite the same. On the other hand I was able to proof that the program flow was quite correct, only the breakpoints were reached or not reached reproducably but not as expected. The real program flow was exactly as expected. So I decided for me to always set the optimization to "none" while debugging.
Since the optimization level can be set individually for every file you can save lots of bits and mips when lowering the level only for the files under test.
At the recent Customer Advisory Board (CAB) at Cypress in Portland we suggested to default the optimization level for the generated files to a high level.