https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64052
Georg-Johann Lay <gjl at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gjl at gcc dot gnu.org --- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> --- I think this PR is invalid: Your code rets up avariable which needs a place to be stored, which is the function frame for non-optimized code. As the function is naked, no frame is available to store the value. If the compiler would not check this and proceed compilation, the resulting code would be non-functional. This is similar for C. Consider extern void fun (int*); __attribute__((naked)) void test (void) { int x; fun (&x); } There's no place to store x here, and this even applies to optimized code. Apart from this, the documentation for "naked" attribute reads: >> [...] It allows the compiler to construct the requisite function >> declaration, while allowing the body of the function to be >> assembly code. >> [...] Only Basic asm statements can safely be included in naked >> functions. While using Extended asm or a mixture of Basic asm >> and C code may appear to work, they cannot be depended upon to >> work reliably and are not supported.