https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124218
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Chris Copeland from comment #3) There is already a barrier instruction and a > "memory" clobber internal to the semaphore functions when a context switch > can occur. I suspect there is a missing atomic_signal_fence/__atomic_signal_fence in the FreeRTOS code to provide a true signal barrier. (an inline-asm is not barrier for signals nor threads in C11+ which is what you running into here I think).
