[Bug c/19571] New: floating point registers not preserved during function call

jack at cs dot york dot ac dot uk gcc-bugzilla@gcc.gnu.org
Fri Jan 21 23:47:00 GMT 2005

The code generator for the ARM target does not preserve register f5 (and
possibly other floating point registers) when they are clobbered by a function.
Thus, if function uses those registers and calls another function which uses
them too, the caller behaves weirdly.

The bug has been found in GCC version 3.4.3 while cross-compiling using an i386.
However it also exists in much earlier versions, including 2.95.x (see bug 19547).

The attached test case demonstrates the bug. main() (in demo.c) calls __cos,
which is defined in s_sin.c. s_sin.c has been taken verbatim from glibc 2.3.3,
along with all the source code required to allow it to compile, which I have
included in the test case for your convenience. During the call to __cos, the
register f5 is clobbered. This is a problem, because main() is using it to store
the value of variable s.

Please note that this is not a glibc bug. __cos is written entirely in C, and
therefore (as far as I can see) this is a problem with the compiler.

The test case may be built using the build.sh script.

An execution transcript has been included (transcript.txt), along with a
disassembly of the functions involved (disassembly.txt). Bug 19547 has more
details about the bug too, and I am happy to send you more information if you
need it.

           Summary: floating point registers not preserved during function
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jack at cs dot york dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-unknown-linux
  GCC host triplet: i686-unknown-linux
GCC target triplet: arm-unknown-linux


More information about the Gcc-bugs mailing list