I think this is a bug in CMSIS. The __get_PRIMASK () intrinsic implementation in cmsis_gcc.h needs to have a memory clobber in the inline asm statement to prevent it from being reordered.
I think this is a bug in CMSIS. The __get_PRIMASK () intrinsic implementation in cmsis_gcc.h needs to have a memory clobber in the inline asm statement to prevent it from being reordered.