This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: ABI mismatch for single precision floating point return between C and Fortran
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Gerhard Tonn <GerhardTonn at swol dot de>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 15 Mar 2002 23:17:52 +0100
- Subject: Re: ABI mismatch for single precision floating point return between C and Fortran
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <02031517580200.00800@tau>
Gerhard Tonn wrote:
> when I compile and link the following two small programs on the S/390
> architecture, I get a wrong result from the C function. This is caused by the
> fact that according to the ABI on S/390 a float is returned as single
> precision float, but Fortran expects that it is returned as double (that is
> what the assembler says).
Doh ! It's certainly not what the Fortran code says ... SDOTTESTC is an
implicitly typed function (type REAL), so it should match a float
function in C.
> Does anyone know, if this is somehow tied to Fortran or if I can change this
> behaviour by any backend switches. The problem occurs with 2.95.4, 3.0.4 and
> the latest 3.1 snapshot.
As far as I can see, if your analysis is correct, this is a bug. I
don't know yet which part of the compiler is to blame, but it is not
correct.
> Btw, the same problem seems to appear on sparc.
Yes, I recall (now that I see this example) that we had an earlier GNATS
report that had a similar problem on sparc (don't know the number
off-hand).
> PROGRAM TST
> * .. Parameters ..
> INTEGER NOUT
> PARAMETER (NOUT=6)
> REAL EC
> * .. External Subroutines ..
> EXTERNAL SDOTTESTC
>
> EC=SDOTTESTC()
>
> WRITE (NOUT,99997) EC
> RETURN
> 99997 FORMAT(2E12.4)
> END
>
> float
> sdottestc_()
> {
> float e = 1.34;
> printf("%e\n", e);
> return e;
> }
I'll look into it this weekend (provided I can reproduce it on one of
the targets I have at home: i686-*-linux-gnu, alphaev6-*-linux-gnu or
powerpc-*-linux-gnu).
Thanks for the analysis !
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)