This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Failure of default_format_1.f90


It appears that either your testcase is bogus or (as I feared)
you broke gfortran cratering to the darwin platform.

I have not committed any patch addressing a darwin issue (except xfailing two testcases after having shown that darwin system libraries were broken; see below). Please refrain from unsubstantiated claims, as it's really counterproductive (and, on this occasion, doesn't give me ). I have already said I do understand your concerns that maintainability is a key element in evaluating bugs and patches, and I'll stick to it. You can review the patch that caused this, and tell me how it burdens maintainance:


2007-10-02 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

        PR fortran/33469
        * io/write.c (write_real): Widen the default formats.

--- trunk/libgfortran/io/write.c	2007/10/02 20:56:47	128966
+++ trunk/libgfortran/io/write.c	2007/10/02 23:27:51	128967
@@ -698,18 +698,18 @@
   switch (length)
     {
     case 4:
-      f.u.real.w = 14;
-      f.u.real.d = 7;
+      f.u.real.w = 15;
+      f.u.real.d = 8;
       f.u.real.e = 2;
       break;
     case 8:
-      f.u.real.w = 23;
-      f.u.real.d = 15;
+      f.u.real.w = 25;
+      f.u.real.d = 17;
       f.u.real.e = 3;
       break;
     case 10:
-      f.u.real.w = 28;
-      f.u.real.d = 19;
+      f.u.real.w = 29;
+      f.u.real.d = 20;
       f.u.real.e = 4;
       break;
     case 16:



As for the failure, you don't say which target you're talking about, but I take it to be x86_64-freebsd. That means that writing denormals and reading them back doesn't yield the same value. Now, this could be because the field is not large enough, but then it'd be a generic x86 failure, no freebsd specific (testcase works fine on x86_64- linux). So, it's probably a problem with freebsd's printf().

$ cat u.f90
program p
  real(kind=8) :: x, y
  character(len=100) :: s
  print '(I0,1X,I0)', digits(1.d0), precision(1.d0)

  x = tiny(x)
  write (s,*) x
  read (s,*) y
  print *, x
  print *, y

  x = 2.22507385850710603d-308
  write (s,*) x
  read (s,*) y
  print *, x
  print *, y
end program p
$ gfortran u.f90 && ./a.out
53 15
  2.22507385850720138E-308
  2.22507385850720138E-308
  2.22507385850710603E-308
  2.22507385850710603E-308


I've already seen such failures on Darwin (both ppc and x86) and have thus xfail'ed this testcase there, I can add freebsd to that xfail target list. Or, I could just tweak the testcase not to test denormals (patch provided below), but I think there's no reason to treat them separately.


Index: default_format_1.f90
===================================================================
--- default_format_1.f90        (revision 128992)
+++ default_format_1.f90        (working copy)
@@ -86,15 +86,15 @@ program main
   if (test (1.0_4, 0) /= 0) call abort
   if (test (0.0_4, 0) /= 0) call abort
-  if (test (tiny(0.0_4), 0) /= 0) call abort
-  if (test (-tiny(0.0_4), 0) /= 0) call abort
+  if (test (tiny(0.0_4), 1) /= 0) call abort
+  if (test (-tiny(0.0_4), -1) /= 0) call abort
   if (test (huge(0.0_4), -1) /= 0) call abort
   if (test (-huge(0.0_4), 1) /= 0) call abort
   if (test (1.0_8, 0) /= 0) call abort
   if (test (0.0_8, 0) /= 0) call abort
-  if (test (tiny(0.0_8), 0) /= 0) call abort
-  if (test (-tiny(0.0_8), 0) /= 0) call abort
+  if (test (tiny(0.0_8), 1) /= 0) call abort
+  if (test (-tiny(0.0_8), -1) /= 0) call abort
   if (test (huge(0.0_8), -1) /= 0) call abort
   if (test (-huge(0.0_8), 1) /= 0) call abort
Index: default_format_2.f90
===================================================================
--- default_format_2.f90        (revision 128992)
+++ default_format_2.f90        (working copy)
@@ -56,8 +56,8 @@ program main
   if (test (1.0_kl, 0) /= 0) call abort
   if (test (0.0_kl, 0) /= 0) call abort
-  if (test (tiny(0.0_kl), 0) /= 0) call abort
-  if (test (-tiny(0.0_kl), 0) /= 0) call abort
+  if (test (tiny(0.0_kl), 1) /= 0) call abort
+  if (test (-tiny(0.0_kl), -1) /= 0) call abort
   if (test (huge(0.0_kl), -1) /= 0) call abort
   if (test (-huge(0.0_kl), 1) /= 0) call abort



       x =   2.22507385850710603E-308
 trim(s) =   2.22507385850710603E-308
       y =   2.22507385850710652E-308

program p
  print '(I0,1X,I0)', digits(1.d0), precision(1.d0)
end program p
troutmask:sgk[243] gfc4x -o z p.f90
troutmask:sgk[244] ./z
53 15

1 23456789012345
2.22507385850710652E-308
                ^^^
There are garbage.

One can either check /usr/include/float.h of the expected
number of decimal digits or use real_info->precision to
determine a desirable value.

A desirable value for what? That paragraph leaves me quite puzzled.


Regards,
FX



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