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>, gcc-bugs at gcc dot gnu dot org
- Date: Sat, 16 Mar 2002 13:26:25 +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> <3C927310.4E7AEFE1@moene.indiv.nluug.nl>
Toon Moene wrote:
> 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.
Unfortunately, that's not necessarily true. The reason is that g77
wanted to be compatible with the f2c converter, which, by virtue of the
fact that it converted Fortran to (K&R) C, had to stick to functions
returning double - always.
This is documented here:
http://gcc.gnu.org/onlinedocs/gcc-3.0.3/g77_15.html#SEC548
Please check if adding -fno-f2c to the compile command line solves the
problem for you.
--
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)