Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 2 months ago.
Is it a bug of Mbed Studio when debuging?
Hi, there is a strange thing when debuging using mbed studio (0.6.1). As the .gif illustrated, the code "printf("debug test.\n");" is executed before the code "++count;" when debuging. Why does this happen?
1 Answer
5 years, 2 months ago.
Hello Wang,
This strange "phenomenon" (statements are not executed in the same sequence as specified in the C++/C source code) is usually caused by optimization performed by the compiler when building the binary code. It isn't specific only for the Mbed Studio. One can observe it also when building/debugging with the GCC Arm compiler. To avoid it turn off any optimization when building a project for debugging.