This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: single to double conversion
On Wed, Sep 27, 2006 at 12:55:49PM -0700, Richard E Maine wrote:
> On Sep 27, 2006, at 12:35 PM, Steve Kargl wrote:
>
> >The author of g77 made the decide to use the f2c runtime library.
> >f2c always promotes a single precision function to double
> >precision.
>
> I don't see an obvious way to do that and still conform to the
> Fortran standard. Perhaps I am missing a trick. Or perhaps g77 just
> fails to conform to the Fortran standard there. Having a compiler
> switch to enable a nonconforming behavior is one thing. But having a
> compiler that did not even have the option to conform to the standard
> strikes me as.... um.... problematic.
>
> The nonconformance might not show up in most codes, but it sure isn't
> hard to come up with a case of valid Fortran code that would fail
> under such an implementation. Consider
>
> call sub(f(x))
>
> where f(x) returns a (single precision) real, and sub has a (single
> precision) real dummy argument. If f(x) is implemented to return a
> double instead of a single, then its result isn't going to be valid
> as an actual argument for sub. But if sub is separately compiled,
> there won't be an opportunity for the compiler to detect or fix the
> problem.
>
> Perhaps I'm misunderstanding what was going on here, but I'm at least
> a little suspicious that you've just described a way in which g77
> violates the standard (which is different from extending it).
>
I would need to wander around in g77 code to confirm my guess,
but I suspect it does a thunk (ie there are shims). Consider
libf2c code for tan().
This is r_tan.c
#include "f2c.h"
#undef abs
#include <math.h>
double
r_tan (real * x)
{
return (tan (*x));
}
This is d_tan.c
#include "f2c.h"
#undef abs
#include <math.h>
double
d_tan (doublereal * x)
{
return (tan (*x));
}
--
Steve