ABI mismatch for single precision floating point return between C and Fortran

Toon Moene toon@moene.indiv.nluug.nl
Sat Mar 16 04:26:00 GMT 2002


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)



More information about the Gcc-bugs mailing list