[EMAIL PROTECTED] prologue]$ cat bar.i struct bar { short word; struct bar* next; }; int foo (struct bar* c, int w, int delta) { int i; if (c==((void *)0)) return w; i = foo (c->next, w, delta) + delta; c->word = i; return i; } [EMAIL PROTECTED] prologue]$ /usr/gcc-4.0/bin/gcc -S -O2 bar.i [EMAIL PROTECTED] prologue]$ head -15 bar.s .file "bar.i" .text .p2align 4,,15 .globl foo .type foo, @function foo: .LFB2: movq %rbx, -16(%rsp) .LCFI0: movq %rbp, -8(%rsp) .LCFI1: subq $16, %rsp .LCFI2: testq %rdi, %rdi movq %rdi, %rbx
We are putting values beyond the end of the stack. It is wrong and unsafe. We should adjust the stack first. This regression is introduced by http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01666.html -- Summary: [3.4/4.0/4.1 Regression]: ix86 prologue puts values beyond stack Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: major Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hjl at lucon dot org GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24419