Showing results for 
Search instead for 
Did you mean: 

STM32C0 compiler bug: breakpoint jumping to wrong location

Associate II

I am compiling for the STM32C031C6 (development board)

I have optimization set to -Os because otherwise we are not going to fit a simple stack.

In normal compilation mode everything is working as expected. (except for a bug I am chasing now)

So I have 2 pieces of code in the same statemachine:


test_fsm = TEST_TX_1B;



test_fsm = TEST_TX_1B;



Both will result in leaving the calling function so I understand that the compiler has optimized those to the same assembly code.

Now comes the problem:

When I set a breakpoint to one of the two, the code breaks on the other (which is a very common occurrence).

This should not happen and in this case the compiler should have duplicated the code because of the breakpoint.

Please fix this since it costs a lot of time to chase these kind of ghost problems.

thank you


Make sure your project is with compiler optimization zero or minimal. If this fixes it, compare assembly with both cases to confirm the compiler has optimised the code so much that no all C code can have a breakpoint. This applies to any compiler from any vendor, mcu, mpu, cpu.

Lead II

This is NOT a compiler error. The compiler doesn't know anything about your breakpoins. To get simple and precise debugging, turn off the optimization.