public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/24685]  New: real(10) formatted input is broken for huge values
@ 2005-11-05 19:34 jblomqvi at cc dot hut dot fi
  2005-11-05 23:24 ` [Bug libfortran/24685] " fxcoudert at gcc dot gnu dot org
                   ` (37 more replies)
  0 siblings, 38 replies; 40+ messages in thread
From: jblomqvi at cc dot hut dot fi @ 2005-11-05 19:34 UTC (permalink / raw)
  To: gcc-bugs

Seems that the parsing routines cannot deal with big values:

! { dg-do run }
! { dg-require-effective-target fortran_large_real }
program huge_real10_formatted
  ! This should be kind=10 on systems that support it
  integer, parameter :: k = selected_real_kind (precision (0.0_8) + 1)
  real(kind=k) :: a,b(2), c
  character(len=180) :: tmp
  ! Test real(k) scalar and array formatted IO with big value
  b(:) = huge (1.0_k)/2
  print *, 'real(10) big value: ', b(1)
  write (tmp, *) b
  read (tmp, *) a, c
  print *, 'same value read again: ', a
  print *, 'difference: ', a-b(1)
  ! Test with really big value
  b(:) = huge (1.0_k)
  print *, 'huge value: ', b(1)
  write (tmp, *) b
  read (tmp, *) a, c ! This is line 19
  print *, "We don't get this far!"
  if (a /= b(1)) call abort ()
  if (c /= b(2)) call abort ()
end program huge_real10_formatted

Running this produces:

 real(10) big value:   5.948657476786159E+4931
 same value read again:   5.948657476786159E+4931
 difference:   1.751052108159553E+4915
 huge value:   1.189731495357232E+4932
At line 19 of file huge_real10_formatted.f90
Fortran runtime error: Range error during floating point read

Looking at the difference, there also seems to be some problem with
arithmetic..


-- 
           Summary: real(10) formatted input is broken for huge values
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jblomqvi at cc dot hut dot fi
  GCC host triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(10) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
@ 2005-11-05 23:24 ` fxcoudert at gcc dot gnu dot org
  2006-02-05 22:20 ` [Bug libfortran/24685] [4.1 only] " fxcoudert at gcc dot gnu dot org
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-11-05 23:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2005-11-05 23:24 -------
> Looking at the difference, there also seems to be some problem with
> arithmetic..

No, it's only that the default format is not wide enough :)
Compared to other compilers, we could probably do something like:

Index: io/write.c
===================================================================
--- io/write.c  (revision 106521)
+++ io/write.c  (working copy)
@@ -1375,8 +1375,8 @@
       f.u.real.e = 3;
       break;
     case 10:
-      f.u.real.w = 24;
-      f.u.real.d = 15;
+      f.u.real.w = 40;
+      f.u.real.d = 31;
       f.u.real.e = 4;
       break;
     case 16:


And, accidentaly, the above patch fixes your testcase completely, although I
don't know why.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|                            |i686-pc-linux-gnu
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-05 23:24:13
               date|                            |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] [4.1 only] real(10) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
  2005-11-05 23:24 ` [Bug libfortran/24685] " fxcoudert at gcc dot gnu dot org
@ 2006-02-05 22:20 ` fxcoudert at gcc dot gnu dot org
  2006-02-05 23:04 ` fxcoudert at gcc dot gnu dot org
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-02-05 22:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2006-02-05 22:19 -------
OK, now I understand: huge(0._10) is 1.1897314953572317650E+4932. But when you
write it with a format not long enough, you may (as was the case) write it as
1.189731495357232E+4932, which is larger than huge(0._10). So indeed, when you
read it back, it's out of the range accepted for real(10) variables. Changing
the default format for these variables will indeed get rid of all this.

I will commit the trivial patch:

Index: libgfortran/io/write.c
===================================================================
--- libgfortran/io/write.c      (revision 110617)
+++ libgfortran/io/write.c      (working copy)
@@ -1373,8 +1373,8 @@
       f.u.real.e = 3;
       break;
     case 10:
-      f.u.real.w = 24;
-      f.u.real.d = 15;
+      f.u.real.w = 28;
+      f.u.real.d = 19;
       f.u.real.e = 4;
       break;
     case 16:

on trunk after regtesting.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-11-05 23:24:13         |2006-02-05 22:19:58
               date|                            |
            Summary|real(10) formatted input is |[4.1 only] real(10)
                   |broken for huge values      |formatted input is broken
                   |                            |for huge values


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] [4.1 only] real(10) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
  2005-11-05 23:24 ` [Bug libfortran/24685] " fxcoudert at gcc dot gnu dot org
  2006-02-05 22:20 ` [Bug libfortran/24685] [4.1 only] " fxcoudert at gcc dot gnu dot org
@ 2006-02-05 23:04 ` fxcoudert at gcc dot gnu dot org
  2006-02-14 15:48 ` fxcoudert at gcc dot gnu dot org
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-02-05 23:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2006-02-05 23:04 -------
Subject: Bug 24685

Author: fxcoudert
Date: Sun Feb  5 23:04:07 2006
New Revision: 110627

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110627
Log:
        PR libfortran/24685

        * io/write.c (write_real): Widen the default format for real(10)
        variables output.

        * gfortran.dg/large_real_kind_form_io_2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/write.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] [4.1 only] real(10) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (2 preceding siblings ...)
  2006-02-05 23:04 ` fxcoudert at gcc dot gnu dot org
@ 2006-02-14 15:48 ` fxcoudert at gcc dot gnu dot org
  2006-02-14 15:50 ` fxcoudert at gcc dot gnu dot org
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-02-14 15:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2006-02-14 15:47 -------
Subject: Bug 24685

Author: fxcoudert
Date: Tue Feb 14 15:47:49 2006
New Revision: 110975

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110975
Log:
        PR libfortran/24685

        * gfortran.dg/large_real_kind_form_io_2.f90: New test.

        * io/write.c (write_real): Widen the default format for real(10)
        variables output.

Added:
   
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
      - copied unchanged from r110627,
trunk/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/libgfortran/ChangeLog
    branches/gcc-4_1-branch/libgfortran/io/write.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] [4.1 only] real(10) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (3 preceding siblings ...)
  2006-02-14 15:48 ` fxcoudert at gcc dot gnu dot org
@ 2006-02-14 15:50 ` fxcoudert at gcc dot gnu dot org
  2006-02-16 10:55 ` ebotcazou at gcc dot gnu dot org
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-02-14 15:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2006-02-14 15:50 -------
Fixed on both 4.2 and 4.1.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] [4.1 only] real(10) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (4 preceding siblings ...)
  2006-02-14 15:50 ` fxcoudert at gcc dot gnu dot org
@ 2006-02-16 10:55 ` ebotcazou at gcc dot gnu dot org
  2006-02-16 11:12 ` [Bug libfortran/24685] real(16) " fxcoudert at gcc dot gnu dot org
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-02-16 10:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ebotcazou at gcc dot gnu dot org  2006-02-16 10:55 -------
The test doesn't pass on SPARC/Solaris (this is with 4.1):

At line 12 of file
/home/eric/svn/gcc-4_1-branch/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
Fortran runtime error: Range error during floating point read
FAIL: gfortran.dg/large_real_kind_form_io_2.f90  -O0  execution test


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (5 preceding siblings ...)
  2006-02-16 10:55 ` ebotcazou at gcc dot gnu dot org
@ 2006-02-16 11:12 ` fxcoudert at gcc dot gnu dot org
  2006-02-16 17:44 ` pinskia at gcc dot gnu dot org
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-02-16 11:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from fxcoudert at gcc dot gnu dot org  2006-02-16 11:12 -------
OK, I think this is the same bug as reported on some ppc64-linux non-standard
builds. It has to deal with real(16), and is indeed the very same kind of
problem. 
This is not a bug introduced by the patch, it just wasn't exposed by the
previous testcases. I'll investigate. 


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |ASSIGNED
 GCC target triplet|i686-pc-linux-gnu           |sparc-solaris, powerpc64-
                   |                            |linux
   Last reconfirmed|2006-02-05 22:19:58         |2006-02-16 11:12:44
               date|                            |
            Summary|[4.1 only] real(10)         |real(16) formatted input is
                   |formatted input is broken   |broken for huge values
                   |for huge values             |
   Target Milestone|4.1.0                       |4.1.1


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (6 preceding siblings ...)
  2006-02-16 11:12 ` [Bug libfortran/24685] real(16) " fxcoudert at gcc dot gnu dot org
@ 2006-02-16 17:44 ` pinskia at gcc dot gnu dot org
  2006-02-23 17:44 ` sje at cup dot hp dot com
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-16 17:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2006-02-16 17:44 -------
powerpc-darwin has the failure and it supports 128bit long double by default.

powerpc64-linux does not which is why I am removing it from the target.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|sparc-solaris, powerpc64-   |sparc-solaris, powerpc-
                   |linux                       |darwin
   Target Milestone|4.1.1                       |---


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (7 preceding siblings ...)
  2006-02-16 17:44 ` pinskia at gcc dot gnu dot org
@ 2006-02-23 17:44 ` sje at cup dot hp dot com
  2006-03-15  7:29 ` ebotcazou at gcc dot gnu dot org
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: sje at cup dot hp dot com @ 2006-02-23 17:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from sje at cup dot hp dot com  2006-02-23 17:44 -------
I am still seeing this fail on ia64-hp-hpux11.23 which uses real*16.  I believe
the problem is in io/write.c (output_float).  While write_real sets the maximum
width to 40 for real*16, output_float still uses a 32 char buffer in sprintf to
convert the number to a string so we still get more truncation than we should.
I think this buffer should 40+ chars long.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (8 preceding siblings ...)
  2006-02-23 17:44 ` sje at cup dot hp dot com
@ 2006-03-15  7:29 ` ebotcazou at gcc dot gnu dot org
  2006-03-15 16:22 ` jb at gcc dot gnu dot org
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-03-15  7:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from ebotcazou at gcc dot gnu dot org  2006-03-15 07:29 -------
Please XFAIL the testcase on the relevant platforms.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (9 preceding siblings ...)
  2006-03-15  7:29 ` ebotcazou at gcc dot gnu dot org
@ 2006-03-15 16:22 ` jb at gcc dot gnu dot org
  2006-03-15 16:44 ` sje at cup dot hp dot com
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jb at gcc dot gnu dot org @ 2006-03-15 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jb at gcc dot gnu dot org  2006-03-15 16:22 -------
Tentative patch here: http://gcc.gnu.org/ml/gcc-patches/2006-03/msg00950.html


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (10 preceding siblings ...)
  2006-03-15 16:22 ` jb at gcc dot gnu dot org
@ 2006-03-15 16:44 ` sje at cup dot hp dot com
  2006-03-16  8:30 ` jb at gcc dot gnu dot org
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: sje at cup dot hp dot com @ 2006-03-15 16:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from sje at cup dot hp dot com  2006-03-15 16:44 -------
At least on IA64, I don't think there is a way to make this test work.  I tried
a change similar to yours.  I also changed the setting of ndigits (uses the
magic number 27 in a couple of places), changed the number 31 in the sprintf
statement and the number 32 (buffer size) in the snprintf statement.  This
fixed the LDBL_MAX problem but the test still failed on the LDBL_MIN part of
the test.

The attached C program fails on IA64 because the printf rounds the last digit
of MIN_LDBL down when it prints it and so it can't be read back in.  The basic
problem is that LDBL_MAX and LDBL_MIN (or for that matter DBL_MIN and DBL_MAX)
cannot be represented exactly in decimal form so printf has to do some rounding
that may make the process non-reversable when trying to go back via strtod or
strtold.  I looked to see if there was a float or double version of this test
and I didn't find one, if there was one I think it would fail on some platforms
because the write/read sequence is not gauranteed to return the original value
due to possible rounding during the writing and/or reading process.

#include <stdio.h>
#include <float.h>
#include <errno.h>

main()
{
        char buffer[64];
        long double x = LDBL_MIN;
        sprintf(buffer, "%63.40Le", x);
        printf("==%s==\n", buffer);
        errno = 0;
        x = strtold(buffer, 0);
        printf("errno = %d\n", errno);
}


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (11 preceding siblings ...)
  2006-03-15 16:44 ` sje at cup dot hp dot com
@ 2006-03-16  8:30 ` jb at gcc dot gnu dot org
  2006-04-01 21:34 ` ebotcazou at gcc dot gnu dot org
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jb at gcc dot gnu dot org @ 2006-03-16  8:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from jb at gcc dot gnu dot org  2006-03-16 08:30 -------
(In reply to comment #12)
> The attached C program fails on IA64 because the printf rounds the last digit
> of MIN_LDBL down when it prints it and so it can't be read back in.  The basic
> problem is that LDBL_MAX and LDBL_MIN (or for that matter DBL_MIN and DBL_MAX)
> cannot be represented exactly in decimal form so printf has to do some rounding
> that may make the process non-reversable when trying to go back via strtod or
> strtold. 

Ah, I see. Well, IMHO formatted IO of FOO_MAX/MIN is a rather obscure corner
case, so I think a good enough solution would be to change the testcase to
instead test with FOO_MAX/2 and FOO_MIN*2 (just to check that we have large
enough field widths etc. and not worry about rounding out of range). 

But I'll ask the standards gurus on c.l.f first to make sure.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (12 preceding siblings ...)
  2006-03-16  8:30 ` jb at gcc dot gnu dot org
@ 2006-04-01 21:34 ` ebotcazou at gcc dot gnu dot org
  2006-04-01 21:35 ` ebotcazou at gcc dot gnu dot org
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-04-01 21:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from ebotcazou at gcc dot gnu dot org  2006-04-01 21:34 -------
Subject: Bug 24685

Author: ebotcazou
Date: Sat Apr  1 21:34:27 2006
New Revision: 112611

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112611
Log:
        PR libfortran/24685
        * gfortran.dg/large_real_kind_form_io_2.f90: XFAIL on SPARC/Solaris.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (13 preceding siblings ...)
  2006-04-01 21:34 ` ebotcazou at gcc dot gnu dot org
@ 2006-04-01 21:35 ` ebotcazou at gcc dot gnu dot org
  2006-04-10 12:03 ` jakub at gcc dot gnu dot org
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-04-01 21:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from ebotcazou at gcc dot gnu dot org  2006-04-01 21:35 -------
Subject: Bug 24685

Author: ebotcazou
Date: Sat Apr  1 21:35:34 2006
New Revision: 112612

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112612
Log:
        PR libfortran/24685
        * gfortran.dg/large_real_kind_form_io_2.f90: XFAIL on SPARC/Solaris.


Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
   
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (14 preceding siblings ...)
  2006-04-01 21:35 ` ebotcazou at gcc dot gnu dot org
@ 2006-04-10 12:03 ` jakub at gcc dot gnu dot org
  2006-04-21 17:04 ` jakub at gcc dot gnu dot org
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-04-10 12:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from jakub at gcc dot gnu dot org  2006-04-10 12:02 -------
Subject: Bug 24685

Author: jakub
Date: Mon Apr 10 12:02:55 2006
New Revision: 112819

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112819
Log:
        PR libgfortran/24685
        * io/write.c (MIN_FIELD_WIDTH, STR, STR1): Define.
        (output_float): Increase buffer sizes for IEEE quad and IBM extended
        long double.
        (write_real): Output REAL(16) as 1PG43.34E4 rather than 1PG40.31E4.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/write.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (15 preceding siblings ...)
  2006-04-10 12:03 ` jakub at gcc dot gnu dot org
@ 2006-04-21 17:04 ` jakub at gcc dot gnu dot org
  2006-04-21 17:22 ` jakub at gcc dot gnu dot org
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-04-21 17:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from jakub at gcc dot gnu dot org  2006-04-21 17:04 -------
Subject: Bug 24685

Author: jakub
Date: Fri Apr 21 17:04:04 2006
New Revision: 113137

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113137
Log:
        PR libgfortran/24685
        * io/write.c (MIN_FIELD_WIDTH, STR, STR1): Define.
        (output_float): Increase buffer sizes for IEEE quad and IBM extended
        long double.
        (write_real): Output REAL(16) as 1PG43.34E4 rather than 1PG40.31E4.

Modified:
    branches/gcc-4_1-branch/libgfortran/ChangeLog
    branches/gcc-4_1-branch/libgfortran/io/write.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (16 preceding siblings ...)
  2006-04-21 17:04 ` jakub at gcc dot gnu dot org
@ 2006-04-21 17:22 ` jakub at gcc dot gnu dot org
  2006-05-24 18:58 ` fxcoudert at gcc dot gnu dot org
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-04-21 17:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from jakub at gcc dot gnu dot org  2006-04-21 17:22 -------
While this should now be fixed on s390{,x} (and I believe also sparc*)
with -mlong-double-128, it is still broken on powerpc{,64}.
What happens there is that gfortran returns a non-canonical number
for huge (0.0_16) (by non-canonical I mean that the difference between
upper and lower double's exponent is more than 53, in this case
106 or so, particularly upper double is 8.9884656743115795e+307 and
lower double -1.1079139325602226e+276).  libc only cares about 106 fraction
bits, so when printed into buffer, it is already printed the same as
8.9884656743115795e+307 + 0.0 alone (i.e.
8.9884656743115795386465259539451237e+307) and when read back it is read as
8.9884656743115795e+307 + 0.0.  I wonder if gfortran should either always
or at least for the couple of special numbers for the real(16) and complex(16)
kinds choose numbers that are canonical in this sense (and can thus be written
and read back the same).  E.g. when C parses IBM extended long double
constants,
they seem to be always canonical (supposedly because it always rounds to 106
fraction bits).


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amodra at gcc dot gnu dot
                   |                            |org


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (17 preceding siblings ...)
  2006-04-21 17:22 ` jakub at gcc dot gnu dot org
@ 2006-05-24 18:58 ` fxcoudert at gcc dot gnu dot org
  2006-05-24 19:01   ` Andrew Pinski
  2006-05-24 19:01 ` pinskia at physics dot uc dot edu
                   ` (18 subsequent siblings)
  37 siblings, 1 reply; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-24 18:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from fxcoudert at gcc dot gnu dot org  2006-05-24 18:58 -------
(In reply to comment #18)
> it is still broken on powerpc{,64}

Hi Jakub, I'm not sure exactly what is still broken. On
powerpc-apple-darwin7.9.0, with mainline gfortran 20060512:

$ cat foo.f90 
! { dg-do run }
! { dg-require-effective-target fortran_large_real }
program huge_real10_formatted
  ! This should be kind=10 on systems that support it
  integer, parameter :: k = selected_real_kind (precision (0.0_8) + 1)
  real(kind=k) :: a,b(2), c
  character(len=180) :: tmp
  ! Test real(k) scalar and array formatted IO with big value
  b(:) = huge (1.0_k)/2
  print *, 'real(10) big value: ', b(1)
  write (tmp, *) b
  read (tmp, *) a, c
  print *, 'same value read again: ', a
  print *, 'difference: ', a-b(1)
  ! Test with really big value
  b(:) = huge (1.0_k)
  print *, 'huge value: ', b(1)
  write (tmp, *) b
  read (tmp, *) a, c ! This is line 19
  print *, "We don't get this far!"
  if (a /= b(1)) call abort ()
  if (c /= b(2)) call abort ()
end program huge_real10_formatted
$ gfortran foo.f90 && ./a.out 
 real(10) big value:   4.4942328371557897693232629769725618E+0307
 same value read again:   4.4942328371557897693232629769725618E+0307
 difference:    0.000000000000000000000000000000000      
 huge value:   8.9884656743115795386465259539451237E+0307
 We don't get this far!
$ gfortran foo.f90 -mlong-double-128 && ./a.out 
 real(10) big value:   4.4942328371557897693232629769725618E+0307
 same value read again:   4.4942328371557897693232629769725618E+0307
 difference:    0.000000000000000000000000000000000      
 huge value:   8.9884656743115795386465259539451237E+0307
 We don't get this far!

$ cat real16.f90 
  character(len=100) :: a
  real(kind=16) :: x, y, z
  x = huge(x)
  write(a,*) x
  read(a,*) y
  if (x /= y) print *, x, y, x-y
  end
$ gfortran real16.f90 && ./a.out 
$ gfortran real16.f90 -mlong-double-128 && ./a.out


All this looks like it's working fine...


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu dot org
         AssignedTo|fxcoudert at gcc dot gnu dot|unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2006-05-24 18:58 ` fxcoudert at gcc dot gnu dot org
@ 2006-05-24 19:01   ` Andrew Pinski
  0 siblings, 0 replies; 40+ messages in thread
From: Andrew Pinski @ 2006-05-24 19:01 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

> 
> 
> 
> ------- Comment #19 from fxcoudert at gcc dot gnu dot org  2006-05-24 18:58 -------
> (In reply to comment #18)
> > it is still broken on powerpc{,64}
> 
> Hi Jakub, I'm not sure exactly what is still broken. On
> powerpc-apple-darwin7.9.0, with mainline gfortran 20060512:

Darwin is broken a different way and it is a mess that I was trying to fix but it
is still broken because I don't care that much anymore.

-- Pinski


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (18 preceding siblings ...)
  2006-05-24 18:58 ` fxcoudert at gcc dot gnu dot org
@ 2006-05-24 19:01 ` pinskia at physics dot uc dot edu
  2006-05-24 20:35 ` fxcoudert at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: pinskia at physics dot uc dot edu @ 2006-05-24 19:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from pinskia at physics dot uc dot edu  2006-05-24 19:01 -------
Subject: Re:  real(16) formatted input is broken for huge values

> 
> 
> 
> ------- Comment #19 from fxcoudert at gcc dot gnu dot org  2006-05-24 18:58 -------
> (In reply to comment #18)
> > it is still broken on powerpc{,64}
> 
> Hi Jakub, I'm not sure exactly what is still broken. On
> powerpc-apple-darwin7.9.0, with mainline gfortran 20060512:

Darwin is broken a different way and it is a mess that I was trying to fix but
it
is still broken because I don't care that much anymore.

-- Pinski


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (19 preceding siblings ...)
  2006-05-24 19:01 ` pinskia at physics dot uc dot edu
@ 2006-05-24 20:35 ` fxcoudert at gcc dot gnu dot org
  2007-05-25 19:50 ` jvdelisle at gcc dot gnu dot org
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-24 20:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #21 from fxcoudert at gcc dot gnu dot org  2006-05-24 20:34 -------
(In reply to comment #20)
> Darwin is broken a different way and it is a mess that I was trying to fix but
> it is still broken because I don't care that much anymore.

Could you give a Fortran testcase that is not behaving as expected?


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|http://gcc.gnu.org/ml/gcc-  |
                   |patches/2006-               |
                   |04/msg00264.html            |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (20 preceding siblings ...)
  2006-05-24 20:35 ` fxcoudert at gcc dot gnu dot org
@ 2007-05-25 19:50 ` jvdelisle at gcc dot gnu dot org
  2007-05-26 17:51 ` dominiq at lps dot ens dot fr
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-05-25 19:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #22 from jvdelisle at gcc dot gnu dot org  2007-05-25 19:50 -------
Is this still broken or can we close?  I would like to fix this if possible.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (21 preceding siblings ...)
  2007-05-25 19:50 ` jvdelisle at gcc dot gnu dot org
@ 2007-05-26 17:51 ` dominiq at lps dot ens dot fr
  2007-11-03 16:48 ` jvdelisle at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-05-26 17:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #23 from dominiq at lps dot ens dot fr  2007-05-26 17:51 -------
> Is this still broken or can we close?  

As far as I can tell it is still broken
(http://gcc.gnu.org/ml/gcc/2007-05/msg00628.html).

> I would like to fix this if possible.

Me too!-) 

 If Jack Howarth send me a patch for 4.2 I can test it (allow for 15 hours,
pbook G4 12") and can also try to test it on 4.3 (unfortunately I am presently
blocked by a failure with libjava, if it is not fixede soon I'll disable it).


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (22 preceding siblings ...)
  2007-05-26 17:51 ` dominiq at lps dot ens dot fr
@ 2007-11-03 16:48 ` jvdelisle at gcc dot gnu dot org
  2007-11-12  5:44 ` jvdelisle at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-11-03 16:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #24 from jvdelisle at gcc dot gnu dot org  2007-11-03 16:48 -------
Subject: Bug 24685

Author: jvdelisle
Date: Sat Nov  3 16:47:37 2007
New Revision: 129871

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129871
Log:
2007-11-03  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/24685
        * gfortran.dg/default_format_2.f90: XFAIL powerpc*-*-linux*
        * gfortran.dg/default_format_denormal_2.f90: XFAIL powerpc*-*-linux*
        * gfortran.dg/large_real_kind_form_io_2.f90: XFAIL powerpc*-*-linux*

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/default_format_2.f90
    trunk/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90
    trunk/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (23 preceding siblings ...)
  2007-11-03 16:48 ` jvdelisle at gcc dot gnu dot org
@ 2007-11-12  5:44 ` jvdelisle at gcc dot gnu dot org
  2008-01-17 11:24 ` [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90) burnus at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-11-12  5:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #25 from jvdelisle at gcc dot gnu dot org  2007-11-12 05:44 -------
This is now:

[Bug libc/5268] huge and denornal reads and writes for long doubles

http://sourceware.org/bugzilla/show_bug.cgi?id=5268


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (24 preceding siblings ...)
  2007-11-12  5:44 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-17 11:24 ` burnus at gcc dot gnu dot org
  2008-01-17 15:33 ` ebotcazou at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-17 11:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #26 from burnus at gcc dot gnu dot org  2008-01-17 10:49 -------
Add gfortran.dg/default_format_2.f90 to the summary as that test case points
here.

It seems to fail also for s390-ibm-linux-gnu (for "test (1.0_kl, 0)") and for 
sparc-unknown-linux-gnu (these are not yet XFAILED). XFAILed are currently:
   powerpc*-apple-darwin* *-*-freebsd* powerpc*-*-linux*
However, the target field of this PR shows: "sparc-solaris, powerpc-darwin". Is
sparc-solaris also affected or not?


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|real(16) formatted input is |real(16) formatted input is
                   |broken for huge values      |broken for huge values
                   |                            |(gfortran.dg/default_format_
                   |                            |2.f90)


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (25 preceding siblings ...)
  2008-01-17 11:24 ` [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90) burnus at gcc dot gnu dot org
@ 2008-01-17 15:33 ` ebotcazou at gcc dot gnu dot org
  2008-01-24 15:09 ` dominiq at lps dot ens dot fr
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-01-17 15:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #27 from ebotcazou at gcc dot gnu dot org  2008-01-17 13:11 -------
> Add gfortran.dg/default_format_2.f90 to the summary as that test case points
> here.

But this is confusing, as demonstrated by...

> It seems to fail also for s390-ibm-linux-gnu (for "test (1.0_kl, 0)")
> and for sparc-unknown-linux-gnu (these are not yet XFAILED). XFAILed are
> currently:
>    powerpc*-apple-darwin* *-*-freebsd* powerpc*-*-linux*
> However, the target field of this PR shows: "sparc-solaris, powerpc-darwin".
> Is sparc-solaris also affected or not?

...this. No, gfortran.dg/default_format_2.f90 doesn't fail on SPARC/Solaris.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (26 preceding siblings ...)
  2008-01-17 15:33 ` ebotcazou at gcc dot gnu dot org
@ 2008-01-24 15:09 ` dominiq at lps dot ens dot fr
  2008-01-25 15:47 ` dominiq at lps dot ens dot fr
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-01-24 15:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #28 from dominiq at lps dot ens dot fr  2008-01-24 14:01 -------
Some remarks from powerpc-apple-darwin9:

(1) the title is misleading: formatted inputs are not broken, formatted outputs
are.

(2) they seem broken for constants nearest from bellow any power of two, as
shown by the following code:

[karma] bug/real16% cat real_16_red.f90
real(16) :: x
x = 1.0_16
print *, nearest(x,-x), nearest(x,x)
print *, nearest(1.0_16,-1.0_16), nearest(1.0_16,1.0_16)
end
[karma] bug/real16% gfc -fno-range-check real_16_red.f90
[karma] bug/real16% a.out 
  0.99999999999999999999999999999998767        
1.0000000000000000000000000000000247      
  1.00000000000000000000000000000000000       
1.00000000000000000000000000000002465      

where  nearest(1.0_16,-1.0_16) is ouput as 1.0...0 and not as 0.9...98767.

(3) As huge(1.0_16) is treated as a constant, I had to pay hide-and-seek with
gfortran in the following code:

[karma] bug/real16% cat huge_16.f90
character(80) :: tmp
real(16) :: x, y
x = 2.0_16**1022
print *, 2.0_16*x, 2.0_16*x-huge(x) ! 2.0_16**1023 is larger than huge(x) but
not printed as +Inf
y = nearest(4.0_16*x,-x)
print *, 4.0_16*x, nearest(2.0_16*x,x), nearest(y,-x)

x = nearest(2.0_16*x,-x)   ! hide huge in a variable
print *, x, x-huge(x)

write(tmp,*) x
read(tmp,*) y
print *, x, y, x-y        ! the printed value of y is not the same the one for
x

x = nearest(x,1.0_16)
print *, x, nearest(x,1.0_16)

print *, 8.98846567431157953864652595394512367E+0307_16
end
[karma] bug/real16% gfc -fno-range-check huge_16.f90
[karma] bug/real16% a.out
  8.98846567431157953864652595394512367E+0307 
1.10791393256022264271830208461724263E+0276
                                    +Infinity 
8.98846567431157953864652595394534525E+0307                                   
+Infinity
  8.98846567431157953864652595394501288E+0307  
0.0000000000000000000000000000000000      
  8.98846567431157953864652595394501288E+0307 
8.98846567431157953864652595394512367E+0307  
0.0000000000000000000000000000000000      
  8.98846567431157953864652595394512367E+0307 
8.98846567431157953864652595394534525E+0307
                                    +Infinity

where x is an hidden huge(x), correctly printed as
8.98846567431157953864652595394501288E+0307, correctly read as y (x-y==0.0),
while y is printed as 8.98846567431157953864652595394534525E+0307==+Inf.

Note also several value above huge(x) not printed as +Inf.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (27 preceding siblings ...)
  2008-01-24 15:09 ` dominiq at lps dot ens dot fr
@ 2008-01-25 15:47 ` dominiq at lps dot ens dot fr
  2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-01-25 15:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #29 from dominiq at lps dot ens dot fr  2008-01-25 15:40 -------
see also pr32841.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (28 preceding siblings ...)
  2008-01-25 15:47 ` dominiq at lps dot ens dot fr
@ 2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
  2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-02-23 20:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #30 from fxcoudert at gcc dot gnu dot org  2008-02-23 20:10 -------
On powerpc-apple-darwin9.2, gfortran.dg/large_real_kind_form_io_2.f90 fails for
that reason:

$ cat a.f90
  real(kind=16) :: a,b
  character(len=180) :: tmp

  b = 8.98846567431157953864652595394501287669662887245e307_16
  write (tmp, *) b
  read (tmp, *) a
  write(*,"(G70.55E4)") b
  write(*,"(G70.55E4)") a
  write(*,"(G70.55E4)") a-b
  if (a /= b) print *, "#####"

end
$ ./bin/gfortran a.f90 && ./a.out
       0.8988465674311579538646525953945123668100000000000000000E+0308
       0.8988465674311579538646525953945123668100000000000000000E+0308
       0.1107913932560222642718302084617242634400000000000000000E+0277
 #####

But, as the following C testcase shows, that's not a gfortran problem, but
rather a libc issue on darwin:

$ cat a.c
#include <stdio.h>
#include <string.h>
int main(void) {
  long double x, y = 8.98846567431157953864652595394501287669662887245e307L;
  char buf[79];
  memset (buf, ' ', sizeof(buf));
  sprintf (buf, "%60.70Lg", y);
  puts (buf);
  sscanf (buf, "%Lg", &x);
  memset (buf, ' ', sizeof(buf));
  sprintf (buf, "%60.70Lg", x);
  puts (buf);
  printf ("%60.70Lg\n", x-y);
  return 0;
}
$ gcc a.c && ./a.out
8.988465674311579538646525953945123668089884894711532863671504057886634e+307
8.988465674311579538646525953945123668089884894711532863671504057886634e+307
1.107913932560222642718302084617242634394213707491304322373697056856707e+276

I have reported that issue to Apple as radar #5761818, we'll see if it is
fixed, but I doubt it (no new PowerPC sold by Apple, and generally little
interest in long double). I have thus XFAILed
gfortran.dg/large_real_kind_form_io_2.f90 on powerpc*-apple-darwin*.

As comment #27 says, this doesn't fail on sparc-solaris, I'm closing this as
INVALID. Please reopen if you have a testcase on another target where the issue
is not due to a faulty libc.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (29 preceding siblings ...)
  2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
@ 2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
  2008-02-28  7:10 ` uros at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-02-23 20:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #31 from fxcoudert at gcc dot gnu dot org  2008-02-23 20:11 -------
Subject: Bug 24685

Author: fxcoudert
Date: Sat Feb 23 20:10:29 2008
New Revision: 132577

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132577
Log:
        PR libfortran/24685
        * gfortran.dg/large_real_kind_form_io_2.f90: XFAIL on
        powerpc*-apple-darwin*.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (30 preceding siblings ...)
  2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
@ 2008-02-28  7:10 ` uros at gcc dot gnu dot org
  2008-12-12 22:20 ` janis at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: uros at gcc dot gnu dot org @ 2008-02-28  7:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #32 from uros at gcc dot gnu dot org  2008-02-28 07:09 -------
Subject: Bug 24685

Author: uros
Date: Thu Feb 28 07:08:51 2008
New Revision: 132737

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132737
Log:
        PR target/25477
        * gcc/config/darwin-protos.h: Add darwin_patch_builtins prototype.
        * gcc/config/darwin-ppc-ldouble-patch.def: New file.
        * gcc/config/rs6000/darwin.h (SUBTARGET_INIT_BUILTINS): New macro.
        * gcc/config/rs6000/rs6000.c (rs6000_init_builtins): Call
        SUBTARGET_INIT_BUILTINS if defined.
        * gcc/config/darwin.c (darwin_patch_builtin,
        darwin_patch_builtins): New functions. 

fortran/ChangeLog:

        PR target/25477
        * trans-expr.c (gfc_conv_power_op): Use BUILT_IN_CPOW{F,,L}.
        * f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_CPOW{F,,L}.
        * trans.h (gfor_fndecl_math_cpow, gfor_fndecl_math_cpowf,
        gfor_fndecl_math_cpowl10, gfor_fndecl_math_cpowl16): Remove.
        * trans-decl.c: Likewise.

testsuite/ChangeLog:

        PR libfortran/24685
        * gfortran.dg/large_real_kind_form_io_2.f90: XFAIL on
        powerpc*-apple-darwin*.
        * gfortran.dg/large_real_kind_2.F90: Split testing of ERF and
        ERFC into gfortran.dg/large_real_kind_3.F90.
        * gfortran.dg/large_real_kind_3.F90: New test.


Added:
    branches/gcc-4_3-branch/gcc/config/darwin-ppc-ldouble-patch.def
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/large_real_kind_3.F90
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/darwin-protos.h
    branches/gcc-4_3-branch/gcc/config/darwin.c
    branches/gcc-4_3-branch/gcc/config/rs6000/darwin.h
    branches/gcc-4_3-branch/gcc/config/rs6000/rs6000.c
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/f95-lang.c
    branches/gcc-4_3-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_3-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_3-branch/gcc/fortran/trans.h
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/large_real_kind_2.F90
   
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (31 preceding siblings ...)
  2008-02-28  7:10 ` uros at gcc dot gnu dot org
@ 2008-12-12 22:20 ` janis at gcc dot gnu dot org
  2008-12-12 22:23 ` janis at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: janis at gcc dot gnu dot org @ 2008-12-12 22:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #33 from janis at gcc dot gnu dot org  2008-12-12 22:18 -------
Subject: Bug 24685

Author: janis
Date: Fri Dec 12 22:17:31 2008
New Revision: 142724

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142724
Log:
        PR libgfortran/24685
        * gfortran.dg/default_format_denormal_2.f90: Change XFAIL to check
        for size of long double.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (32 preceding siblings ...)
  2008-12-12 22:20 ` janis at gcc dot gnu dot org
@ 2008-12-12 22:23 ` janis at gcc dot gnu dot org
  2008-12-19  1:39 ` howarth at nitro dot med dot uc dot edu
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: janis at gcc dot gnu dot org @ 2008-12-12 22:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #34 from janis at gcc dot gnu dot org  2008-12-12 22:22 -------
Subject: Bug 24685

Author: janis
Date: Fri Dec 12 22:21:14 2008
New Revision: 142725

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142725
Log:
        PR libgfortran/24685
        * gfortran.dg/default_format_denormal_2.f90: Change XFAIL to check
        for size of long double.

Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
   
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (33 preceding siblings ...)
  2008-12-12 22:23 ` janis at gcc dot gnu dot org
@ 2008-12-19  1:39 ` howarth at nitro dot med dot uc dot edu
  2008-12-19 17:51 ` janis at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2008-12-19  1:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #35 from howarth at nitro dot med dot uc dot edu  2008-12-19 01:38 -------
Revision 142724 causes...

FAIL: gfortran.dg/default_format_denormal_2.f90  -O0  execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -O1  execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -O2  execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -O3 -fomit-frame-pointer 
execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -O3 -fomit-frame-pointer
-funroll-loops  execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -O3 -g  execution test
FAIL: gfortran.dg/default_format_denormal_2.f90  -Os  execution test

on powerpc-apple-darwin8.5.0.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (34 preceding siblings ...)
  2008-12-19  1:39 ` howarth at nitro dot med dot uc dot edu
@ 2008-12-19 17:51 ` janis at gcc dot gnu dot org
  2008-12-19 18:15 ` janis at gcc dot gnu dot org
  2008-12-19 18:23 ` janis at gcc dot gnu dot org
  37 siblings, 0 replies; 40+ messages in thread
From: janis at gcc dot gnu dot org @ 2008-12-19 17:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #36 from janis at gcc dot gnu dot org  2008-12-19 17:50 -------
I'll revert the patch that changes the XFAIL.  I noticed yesterday that the
test was failing on powerpc64-linux on a distribution that I hadn't tested on
before, although the new XFAIL had worked on the other distributions I tried.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (35 preceding siblings ...)
  2008-12-19 17:51 ` janis at gcc dot gnu dot org
@ 2008-12-19 18:15 ` janis at gcc dot gnu dot org
  2008-12-19 18:23 ` janis at gcc dot gnu dot org
  37 siblings, 0 replies; 40+ messages in thread
From: janis at gcc dot gnu dot org @ 2008-12-19 18:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #37 from janis at gcc dot gnu dot org  2008-12-19 18:14 -------
Subject: Bug 24685

Author: janis
Date: Fri Dec 19 18:12:40 2008
New Revision: 142840

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142840
Log:
        Revert:
        2008-12-12  Janis Johnson  <janis187@us.ibm.com>
        PR libgfortran/24685
        * gfortran.dg/default_format_denormal_2.f90: Change XFAIL to check
        for size of long double.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90)
  2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
                   ` (36 preceding siblings ...)
  2008-12-19 18:15 ` janis at gcc dot gnu dot org
@ 2008-12-19 18:23 ` janis at gcc dot gnu dot org
  37 siblings, 0 replies; 40+ messages in thread
From: janis at gcc dot gnu dot org @ 2008-12-19 18:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #38 from janis at gcc dot gnu dot org  2008-12-19 18:22 -------
Subject: Bug 24685

Author: janis
Date: Fri Dec 19 18:20:41 2008
New Revision: 142841

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142841
Log:
        Revert:
        2008-12-12  Janis Johnson  <janis187@us.ibm.com>
        PR libgfortran/24685
        * gfortran.dg/default_format_denormal_2.f90: Change XFAIL to check
        for size of long double.

Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
   
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2008-12-19 18:23 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-05 19:34 [Bug libfortran/24685] New: real(10) formatted input is broken for huge values jblomqvi at cc dot hut dot fi
2005-11-05 23:24 ` [Bug libfortran/24685] " fxcoudert at gcc dot gnu dot org
2006-02-05 22:20 ` [Bug libfortran/24685] [4.1 only] " fxcoudert at gcc dot gnu dot org
2006-02-05 23:04 ` fxcoudert at gcc dot gnu dot org
2006-02-14 15:48 ` fxcoudert at gcc dot gnu dot org
2006-02-14 15:50 ` fxcoudert at gcc dot gnu dot org
2006-02-16 10:55 ` ebotcazou at gcc dot gnu dot org
2006-02-16 11:12 ` [Bug libfortran/24685] real(16) " fxcoudert at gcc dot gnu dot org
2006-02-16 17:44 ` pinskia at gcc dot gnu dot org
2006-02-23 17:44 ` sje at cup dot hp dot com
2006-03-15  7:29 ` ebotcazou at gcc dot gnu dot org
2006-03-15 16:22 ` jb at gcc dot gnu dot org
2006-03-15 16:44 ` sje at cup dot hp dot com
2006-03-16  8:30 ` jb at gcc dot gnu dot org
2006-04-01 21:34 ` ebotcazou at gcc dot gnu dot org
2006-04-01 21:35 ` ebotcazou at gcc dot gnu dot org
2006-04-10 12:03 ` jakub at gcc dot gnu dot org
2006-04-21 17:04 ` jakub at gcc dot gnu dot org
2006-04-21 17:22 ` jakub at gcc dot gnu dot org
2006-05-24 18:58 ` fxcoudert at gcc dot gnu dot org
2006-05-24 19:01   ` Andrew Pinski
2006-05-24 19:01 ` pinskia at physics dot uc dot edu
2006-05-24 20:35 ` fxcoudert at gcc dot gnu dot org
2007-05-25 19:50 ` jvdelisle at gcc dot gnu dot org
2007-05-26 17:51 ` dominiq at lps dot ens dot fr
2007-11-03 16:48 ` jvdelisle at gcc dot gnu dot org
2007-11-12  5:44 ` jvdelisle at gcc dot gnu dot org
2008-01-17 11:24 ` [Bug libfortran/24685] real(16) formatted input is broken for huge values (gfortran.dg/default_format_2.f90) burnus at gcc dot gnu dot org
2008-01-17 15:33 ` ebotcazou at gcc dot gnu dot org
2008-01-24 15:09 ` dominiq at lps dot ens dot fr
2008-01-25 15:47 ` dominiq at lps dot ens dot fr
2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
2008-02-23 20:11 ` fxcoudert at gcc dot gnu dot org
2008-02-28  7:10 ` uros at gcc dot gnu dot org
2008-12-12 22:20 ` janis at gcc dot gnu dot org
2008-12-12 22:23 ` janis at gcc dot gnu dot org
2008-12-19  1:39 ` howarth at nitro dot med dot uc dot edu
2008-12-19 17:51 ` janis at gcc dot gnu dot org
2008-12-19 18:15 ` janis at gcc dot gnu dot org
2008-12-19 18:23 ` janis at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).