https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101354
Bug ID: 101354 Summary: [11/12 regression] naked function mishandled - store optimized away Product: gcc Version: 11.0 URL: https://godbolt.org/z/4T4x8eb4f Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: 2-gnu at 0x2c dot org Target Milestone: --- Stores are optimized away when a pointer is passed to a naked function. Discovered in Nordic nRF5-SDK (17.0.2), which uses such a construct to implement syscalls. Minimal example: __attribute__((naked)) //// switching to O0 will make it work //__attribute__((optimize("O0"))) static void extfun_ptr(int *a) { __asm volatile(""); } void fun() { int v; v = 1; extfun_ptr(&v); // &v is never initialized }