Compiler optimization does not produce correct code
Hi there,
I have encouraged a strange behavior inside newlib_lock_glue.c.
On few devices the code does note execute correctly when the optimization is turned on.
To me it looks like the optimization throw away the return and just continue evaluating. the function was called (eventually) from sprintf.
I am running FreeRTOS and thread-safe strategy #4 (allow lock usage from interrupts).
The return is missing from the disassembly and I do not see any instruction that will implement it inside of the if code.
Here is the code with disassembly and callstack
lock is not null
Is the generated assembly correct?
Can you point me to the solution please? I am out of ideas.
This is not my code, newlib_lock_glue.c is generated by CubeIDE
here are mine gcc flags
-mcpu=cortex-m7
-std=gnu11
-g3
-DUSE_HAL_DRIVER
-DSTM32H7A3xx
-DSTM32_THREAD_SAFE_STRATEGY=4
-c
-Os
-ffunction-sections
-fdata-sections
-Wall
-Wextra
-Wshadow
-Wundef
-fstack-usage
--specs=nano.specs
-mfpu=fpv5-d16
-mfloat-abi=hard
-mthumbThank you