This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
RE:cross-compile gcc 4.3, w32api-3.9, W32runtime-3.12 floating point problem
- From: David Lee Braun <dbraun at scripps dot edu>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 10 Apr 2007 11:37:16 -0700
- Subject: RE:cross-compile gcc 4.3, w32api-3.9, W32runtime-3.12 floating point problem
FX Coudert wrote:
>> >> Hello, fortran
>> >> float= **********
>> >> float= **********
>>
> >
> > I think this is a known problem with mingw: the sprintf implementation
> > of the microsoft libraries doesn't handle long doubles correctly. By
> > default, the gfortran I/O routines use the largest floating-point type
> > available to pass values around (which in this case is long double)
> > and to give it to sprintf (we later parse that output for our purposes).
> >
> > I've already proposed a fix for that, but it was felt too intrusive by
> > the GCC win32 maintainer, so we're left with the unsatisfying other
> > solution: patch the Fortran front-end yourself so that it doesn't
> > allow long double variables at all (real(kind=10), that is). The
> > following patch does just this:
> >
> > Index: gcc/fortran/trans-types.c
> > ===================================================================
> > --- gcc/fortran/trans-types.c (revision 123612)
> > +++ gcc/fortran/trans-types.c (working copy)
> > @@ -179,8 +179,10 @@
> > library assumes these are the only floating point types. */
> >
> > if (mode != TYPE_MODE (float_type_node)
> > - && (mode != TYPE_MODE (double_type_node))
> > - && (mode != TYPE_MODE (long_double_type_node)))
> > +#ifndef GFORTRAN_WITHOUT_LONGDOUBLE
> > + && (mode != TYPE_MODE (long_double_type_node))
> > +#endif
> > + && (mode != TYPE_MODE (double_type_node)))
> > continue;
> >
> > /* Let the kind equal the precision divided by 8, rounding up.
> > Again,
> > Index: gcc/config/i386/mingw32.h
> > ===================================================================
> > --- gcc/config/i386/mingw32.h (revision 123612)
> > +++ gcc/config/i386/mingw32.h (working copy)
> > @@ -139,3 +139,8 @@
> > /* mingw32 atexit function is safe to use in shared libraries. Use it
> > to register C++ static destructors. */
> > #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
> > +
> > +/* mingw32 builds the Fortran front-end without support for the
> > + long double type. */
> > +#undef GFORTRAN_WITHOUT_LONGDOUBLE
> > +#define GFORTRAN_WITHOUT_LONGDOUBLE 1
> >
> >
> > Could you try it and report back to us? Thanks,
> > FX
> >
>
Thanks for your reply,
I applied the patch and recompiled. I still have the same problem.
dlb
--
David Lee Braun
Manager of Computational Facilities
for Dr Charles L. Brooks, III
Department of Molecular Biology, TPC6
The Scripps Research Institute
La Jolla, CA 92037
(858) 784-7427
dbraun@scripps.edu