[gfortran] patch for output of real values on windows systems

FX Coudert fxcoudert@gmail.com
Fri Aug 5 23:45:00 GMT 2005


Attached patch (comes with ChangeLog) fixes PR libfortran/23138: the 
system sprintf (that is, the one included in msvcrt.dll) is not able to 
handle long double values (thanks to Danny Smith for the diagnosis!). 
Thus, this patch provides a fallback implementation in that precise case 
(that is, the format is fixed: "%+-#31.*Le", which makes it easy to 
implement). The patch adds a test in aclocal.m4 (with reasonnable guess 
based on ${target} for cross-compilers) to know if sprintf is to be used 
or the fallback.

The provided fallback sprintf is not perfect: it prints incorrect last 
digits (at least, not similar to those printed by GNU libc) when used to 
output very large or very small long double values with high precision 
(more than 15 digits). Any practical suggestion on this is welcome.

Patch was tested as follows:

   * the poor_sprintf() function was checked standalone and compared to 
GNU libc on random floating point values, as well as corner cases 
(infinity, LDBL_MAX, very close to LDBL_MAX, 1.0, very close to 1.0, 
very close to 0.0, 0.0, ...)

   * the total patch was built and tested on i386-mingw32. That does not 
include full regtesting, since the dejagnu framework doesn't work on 
i386-mingw32, but I manually ran some of the many testcases which failed 
before, such as the one in the PR and large_real_1.f90.

   * the total patch was built and regtested on i686-linux.

   * I checked that the configure test performed well on: i386-mingw32, 
i686-linux, x86_64-linux as well as a cross compiler with 
build=host=x86_64-linux and target=i386-mingw32.


OK to commit?

FX

PS: the Windows binaries I post to my website (and which are linked from 
gfortran.org) will be built with this patch. gfortran on windows is 
simply unusable without it.


:ADDPATCH libgfortran:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-sprintf
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050805/938f8b05/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-sprintf.ChangeLog
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050805/938f8b05/attachment-0001.ksh>


More information about the Fortran mailing list