From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28138 invoked by alias); 23 Jan 2008 19:38:18 -0000 Received: (qmail 27948 invoked by uid 48); 23 Jan 2008 19:37:33 -0000 Date: Wed, 23 Jan 2008 20:58:00 -0000 Subject: [Bug c/34947] New: Clobbered float registers not popped X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "vincent dot riviere at freesbee dot fr" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg02796.txt.bz2 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