[Bug fortran/60128] [4.8/4.9 Regression] Wrong ouput using en edit descriptor

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Thu Mar 20 11:04:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60128

--- Comment #28 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> > What we should do is break the test case into two test cases one for quad16 and
> > the other for the rest.  Then we XFAIL the quad16 one for solaris.  I think we
>
> Agreed, that's better than silently exiting a test in certain
> conditions, making it seem that it works while it actually doesn't.

For the later remark, this can be handled with something such as the following
patch:

--- fmt_en_2.f90    2014-03-04 17:51:04.000000000 +0100
+++ fmt_en_3.f90    2014-03-20 11:52:51.000000000 +0100
@@ -2,8 +2,39 @@
 ! PR60128 Invalid outputs with EN descriptors
 ! Test case provided by Walt Brainerd.
 program pr60128
-implicit none
+use ISO_FORTRAN_ENV
+    implicit none
+    integer, parameter :: j(size(real_kinds)+4)=[REAL_KINDS, [4, 4, 4, 4]]
+    logical :: l_skip(4) = .false.
+    integer :: i
     integer :: n_tst = 0, n_cnt = 0
+    character(len=20) :: s
+
+!   Check that the default rounding mode is to nearest and to even on tie.
+    do i=1,size(real_kinds)
+      if (i == 1) then
+        write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(1)), &
+                                  real(9.49999905,kind=j(1)),  &
+                                  real(9.5,kind=j(1)), real(8.5,kind=j(1))
+      else if (i == 2) then
+        write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(2)), &
+                                  real(9.49999905,kind=j(2)),  &
+                                  real(9.5,kind=j(2)), real(8.5,kind=j(2))
+      else if (i == 3) then
+        write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(3)), &
+                                  real(9.49999905,kind=j(3)),  &
+                                  real(9.5,kind=j(3)), real(8.5,kind=j(3))
+      else if (i == 4) then
+        write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(4)), &
+                                  real(9.49999905,kind=j(4)),  &
+                                  real(9.5,kind=j(4)), real(8.5,kind=j(4))
+      end if
+      if (s /= '-9.5 9.5 10.  8.') then
+        l_skip(i) = .true.
+        print "('real(',i0,') are not rounded to nearest')", j(i)
+      end if
+    end do
+        

 ! Original test.
     call checkfmt("(en15.2)", -.44444,    "    -444.44E-03")
@@ -109,18 +140,18 @@ implicit none

     print *, n_tst, n_cnt
     if (n_cnt /= 0) call abort
+    if (all(.not. l_skip)) print *, "no test skipped"

 contains
     subroutine checkfmt(fmt, x, cmp)
         use ISO_FORTRAN_ENV
         implicit none
-        integer, parameter :: j(size(real_kinds)+4)=[REAL_KINDS, [4, 4, 4, 4]]
         integer :: i
         character(len=*), intent(in) :: fmt
         real, intent(in) :: x
         character(len=*), intent(in) :: cmp
-        character(len=20) :: s
         do i=1,size(real_kinds)
+          if (l_skip(i)) cycle
           if (i == 1) then
             write(s, fmt) real(x,kind=j(1))
           else if (i == 2) then
@@ -139,3 +170,4 @@ contains

     end subroutine
 end program
+! { dg-output "no test skipped" { xfail i?86-*-solaris2.9* } }

Splitting the test along the real kinds is difficult to do, as some platforms
don't have real(10) (e.g., powerpc). If the test has to be split, I'ld prefer
to split it along the line 'wrong outputs' (comment 0 and 6)/ 'rounding tests'
(those failing on solaris).



More information about the Gcc-bugs mailing list