This is the mail archive of the gcc-patches@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]

[PATCH] Failure of test default_format_1.f90 on cygwin


Test gfortran.dg/default_format_1.f90 fails on cygwin. The test checks the default formats for formatted I/O of reals are wide enough and have enough precision by writing and reading back floating point values.

On cygwin, the write/read is not exact in a couple of cases, but the error is only in the last bit - a relative error of epsilon(x). While not perfect, I think the tests still pass in spirit.

This patch introduces a small tolerance to the test. If this is not acceptable then I will XFAIL the test.


2009-05-10 David Billinghurst <billingd@gcc.gnu.org>


	* gfortran.dg/default_format_1.inc:  Allow relatve error of
	epsilon(x).

--- default_format_1.inc 2007-10-08 16:31:30.000000000 +1100
+++ default_format_1.inc        2009-05-10 14:20:19.562500000 +1000
@@ -23,7 +23,9 @@
       do i = 0, count
         write (s,*) x
         read (s,*) y
-        if (y /= x) res = res + 1
+        if (y /= x) then
+         if ( (x-y)/max(abs(x),abs(y)) >= 2*epsilon(x) ) res = res + 1
+        end if
         x = nearest(x,huge(x))
       end do
     end if
@@ -33,7 +35,9 @@
       do i = 0, count
         write (s,*) x
         read (s,*) y
-        if (y /= x) res = res + 1
+        if (y /= x) then
+         if ( (x-y)/max(abs(x),abs(y)) >= 2*epsilon(x) ) res = res + 1
+       end if
         x = nearest(x,-huge(x))
       end do
     end if
@@ -55,7 +59,9 @@
       do i = 0, count
         write (s,*) x
         read (s,*) y
-        if (y /= x) res = res + 1
+        if (y /= x) then
+         if ( (x-y)/max(abs(x),abs(y)) >= 2*epsilon(x) ) res = res + 1
+       end if
         x = nearest(x,huge(x))
       end do
     end if
@@ -65,7 +71,9 @@
       do i = 0, count
         write (s,*) x
         read (s,*) y
-        if (y /= x) res = res + 1
+        if (y /= x) then
+         if ( (x-y)/max(abs(x),abs(y)) >= 2*epsilon(x) ) res = res + 1
+        end if
         x = nearest(x,-huge(x))
       end do
     end if


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