This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34947] New: Clobbered float registers not popped
- From: "vincent dot riviere at freesbee dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jan 2008 19:37:33 -0000
- Subject: [Bug c/34947] New: Clobbered float registers not popped
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This problem is about functions that push some float registers at the
beginning, but forget to pop them at the end. The stack pointer is not adjusted
as expected, so the function return to an invalid address.
It appears when the following is true:
- the file is compiled with -m68020-60 -O1 -fomit-frame-pointer
- the function uses floats
- the function is complicated enough to have some float registers backed up on
the stack
- there is an early return in the function
The problem appears in the following test case:
$ cat bug.c
volatile float g1;
float g2;
void f(void)
{
float i;
if (g2 >= 0)
return;
for (i = 0; i < 10; ++i)
g1 = g2 + i;
}
$ gcc -S bug.c -o - -m68020-60 -O2 -fomit-frame-pointer
...
.globl f
.type f, @function
f:
fmovm #0x4,-(%sp)
fmove.s g2,%fp2
fbnge .L9
.L5:
rts
.L9:
...
We can see that some float registers are backuped at the beginning. Then (g2 >=
0) is checked. If it is the case, the function returns with a simple rts,
without restoring the registers, to an invalid address.
This happens in gcc 4.2.2 and gcc-4.2-20080116
--
Summary: Clobbered float registers not popped
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vincent dot riviere at freesbee dot fr
GCC target triplet: m68k-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34947