This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]