public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/43298]  New: fortran library does not read in NaN -Inf or Inf
@ 2010-03-08 21:14 jjcogliati-r1 at yahoo dot com
  2010-03-08 21:17 ` [Bug libfortran/43298] " jjcogliati-r1 at yahoo dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: jjcogliati-r1 at yahoo dot com @ 2010-03-08 21:14 UTC (permalink / raw)
  To: gcc-bugs

As I understand it, fortran should be able to read in a NaN or Inf value.
See 10.6.1.2.1 F editing in the Fortran 2003 specification.  This is a new
Fortran 2003 feature and is not in the Fortran 95 specification.

gfortran properly prints out the NaN values, but cannot read them in, thus
causing the following program to fail:

program nan_test         
  character(15) :: nan = '  NAN -INF  INF'
  real :: a,b,c, d = 0.0

  print ('(3F5.2)'),0.0/d,-1.0/d,1.0/d
  read (nan,'(3F5.2)'),a,b,c
  print *,f

end program nan_test

I have tried with both 4.5.0 20100121 and 4.4.3.


-- 
           Summary: fortran library does not read in NaN -Inf or Inf
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jjcogliati-r1 at yahoo dot com


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
@ 2010-03-08 21:17 ` jjcogliati-r1 at yahoo dot com
  2010-03-09  2:38 ` jvdelisle at gcc dot gnu dot org
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jjcogliati-r1 at yahoo dot com @ 2010-03-08 21:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jjcogliati-r1 at yahoo dot com  2010-03-08 21:17 -------
program should be: (both exhibit the bug though, but this works if bug is not
present)

program nan_test         
  implicit none 
  character(15) :: nan = '  NAN -INF  INF'
  real :: a,b,c, d = 0.0

  print ('(3F5.2)'),0.0/d,-1.0/d,1.0/d
  read (nan,'(3F5.2)'),a,b,c
  print *,a,b,c

end program nan_test


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
  2010-03-08 21:17 ` [Bug libfortran/43298] " jjcogliati-r1 at yahoo dot com
@ 2010-03-09  2:38 ` jvdelisle at gcc dot gnu dot org
  2010-03-09  7:24 ` burnus at gcc dot gnu dot org
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-03-09  2:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2010-03-09 02:38 -------
Confirmed. In io/read.c we have:

/*   TODO: handle not-a-numbers and infinities.  */

I will take this on. But it is back burner to some other issues.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-09 02:38:33
               date|                            |


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
  2010-03-08 21:17 ` [Bug libfortran/43298] " jjcogliati-r1 at yahoo dot com
  2010-03-09  2:38 ` jvdelisle at gcc dot gnu dot org
@ 2010-03-09  7:24 ` burnus at gcc dot gnu dot org
  2010-03-12 12:31 ` burnus at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-03-09  7:24 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 832 bytes --]



------- Comment #3 from burnus at gcc dot gnu dot org  2010-03-09 07:24 -------
Quoting the standard. Note especially that also "NaN(optional)" is valid:

"(1) On input, leading blanks are not significant. When the input field is not
an IEEE exceptional specification (10.6.1.2.1), the interpretation of blanks,
other than leading blanks, is determined by the blank interpretation mode
(10.7.6)." [F2003, 10.6.1, (1)]

"An input field that is an IEEE exceptional specification consists of optional
blanks, followed by either of
(1) an optional sign, followed by the string ’INF’ or the string ’INFINITY’ or
(2) an optional sign, followed by the string ’NAN’, optionally followed by zero
or more alphanumeric characters enclosed in parentheses," [F2003, 10.6.1.2.1]


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (2 preceding siblings ...)
  2010-03-09  7:24 ` burnus at gcc dot gnu dot org
@ 2010-03-12 12:31 ` burnus at gcc dot gnu dot org
  2010-03-12 17:05 ` burnus at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-03-12 12:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2010-03-12 12:31 -------
Actually, in list_read.c's parse_real gfortran already handles inf(inity) and
nan (_but_ _not _"nan(string)"). Thus, using 'read(*,*) a' works.

 * * *

The TODO quote from comment 2 is for read.c's "convert_real"; however, as this
only calls strto(d,f,ld), I do not see a problem on POSIX/C99 systems. I think
the actual problem is read.c's "read_f" which cannot parse NaN/INF and gives a
"goto bad" error. I think one should do something similar to list_read.c's
parse_real.

For completeness, the strtod, strtof, strtold of C99/POSIX supports:
* One of INF or INFINITY, ignoring case
* One of NAN or NAN(n-char-sequence_opt), ignoring case in the NAN part, where:
          n-char-sequence:
              digit
              nondigit
              n-char-sequence digit
              n-char-sequence nondigit


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (3 preceding siblings ...)
  2010-03-12 12:31 ` burnus at gcc dot gnu dot org
@ 2010-03-12 17:05 ` burnus at gcc dot gnu dot org
  2010-04-26  4:45 ` jvdelisle at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-03-12 17:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2010-03-12 17:05 -------
(In reply to comment #4)
> Actually, in list_read.c's parse_real gfortran already handles inf(inity) and
> nan (_but_ _not _"nan(string)"). Thus, using 'read(*,*) a' works.

Also list_read.c's "read_real" handles INF/NAN but not "NaN(...)".

Thus:
- parse_real needs to support NaN(alphanum)
- read_real needs to support NaN(alpanum)
- read_f needs to get Inf+NaN support
- convert_real needs to get the comment updated (assuming POSIX/C99 strtod)


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (4 preceding siblings ...)
  2010-03-12 17:05 ` burnus at gcc dot gnu dot org
@ 2010-04-26  4:45 ` jvdelisle at gcc dot gnu dot org
  2010-06-27 19:46 ` jvdelisle at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-04-26  4:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2010-04-26 04:45 -------
Created an attachment (id=20490)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20490&action=view)
First attempt a a patch to allow reading inf and NaN with parens

This patch implements a filter to extract the inf, infinity, and nan  () forms.
 I am still testing and post it here for others to try if they want.  I may use
a case statement in the final patch. At the moment it is a toss up.


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (5 preceding siblings ...)
  2010-04-26  4:45 ` jvdelisle at gcc dot gnu dot org
@ 2010-06-27 19:46 ` jvdelisle at gcc dot gnu dot org
  2010-06-28  9:09 ` burnus at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-06-27 19:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2010-06-27 19:46 -------
See patch submitted for approval here:

http://gcc.gnu.org/ml/fortran/2010-06/msg00257.html


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (6 preceding siblings ...)
  2010-06-27 19:46 ` jvdelisle at gcc dot gnu dot org
@ 2010-06-28  9:09 ` burnus at gcc dot gnu dot org
  2010-06-28 19:15 ` jvdelisle at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-06-28  9:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from burnus at gcc dot gnu dot org  2010-06-28 09:09 -------
Created an attachment (id=21022)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21022&action=view)
Draft patch for reading NaN(alphanum) in list-directed I/O

While INF/NAN were already supported in list-directed I/O (cf. PR fortran/34319
and PR 34427), NAN(alpanum) was not. Attached is a draft patch to handle it.

That's a separate but related issue to the patch in comment 7 which is about
format-based I/O.


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (7 preceding siblings ...)
  2010-06-28  9:09 ` burnus at gcc dot gnu dot org
@ 2010-06-28 19:15 ` jvdelisle at gcc dot gnu dot org
  2010-06-28 20:05 ` burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-06-28 19:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jvdelisle at gcc dot gnu dot org  2010-06-28 19:15 -------
Tobias,

Your patch is approved.  Also, I managed to get all your comments addressd for
the read_f patch including signs on Inf last night and will resubmit tonight.


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (8 preceding siblings ...)
  2010-06-28 19:15 ` jvdelisle at gcc dot gnu dot org
@ 2010-06-28 20:05 ` burnus at gcc dot gnu dot org
  2010-06-30  1:36 ` jvdelisle at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-06-28 20:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from burnus at gcc dot gnu dot org  2010-06-28 20:05 -------
Subject: Bug 43298

Author: burnus
Date: Mon Jun 28 20:04:40 2010
New Revision: 161510

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161510
Log:
2010-06-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/43298
        * list_read.c (parse_real, read_real): Support NAN(alphanum).

2010-06-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/43298
        * gfortran.dg/nan_6.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/nan_6.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (9 preceding siblings ...)
  2010-06-28 20:05 ` burnus at gcc dot gnu dot org
@ 2010-06-30  1:36 ` jvdelisle at gcc dot gnu dot org
  2010-06-30  1:39 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-06-30  1:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jvdelisle at gcc dot gnu dot org  2010-06-30 01:36 -------
Subject: Bug 43298

Author: jvdelisle
Date: Wed Jun 30 01:35:56 2010
New Revision: 161585

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161585
Log:
2010-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/43298
        * io/read.c: Add code to parse and read Inf, Infinity, NaN, and Nan
with
        optional parenthesis.

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


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (10 preceding siblings ...)
  2010-06-30  1:36 ` jvdelisle at gcc dot gnu dot org
@ 2010-06-30  1:39 ` jvdelisle at gcc dot gnu dot org
  2010-06-30  8:06 ` burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-06-30  1:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from jvdelisle at gcc dot gnu dot org  2010-06-30 01:38 -------
Subject: Bug 43298

Author: jvdelisle
Date: Wed Jun 30 01:38:42 2010
New Revision: 161586

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161586
Log:
2010-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/43298
        * gfortran.dg/read_infnan_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/read_infnan_1.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (11 preceding siblings ...)
  2010-06-30  1:39 ` jvdelisle at gcc dot gnu dot org
@ 2010-06-30  8:06 ` burnus at gcc dot gnu dot org
  2010-07-02  0:12 ` danglin at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-06-30  8:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from burnus at gcc dot gnu dot org  2010-06-30 08:06 -------
(In reply to comment #5)
> - convert_real needs to get the comment updated (assuming POSIX/C99 strtod)

I think that's the only item left to do: Deleting the following TODO from
read.c's convert_real - and then the bug can be closed:

 * argument is properly aligned for the type in question.  TODO:
 * handle not-a-numbers and infinities.  */

(The comment is wrong as strtod handles NAN/INF ...)


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (12 preceding siblings ...)
  2010-06-30  8:06 ` burnus at gcc dot gnu dot org
@ 2010-07-02  0:12 ` danglin at gcc dot gnu dot org
  2010-07-02  7:10 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: danglin at gcc dot gnu dot org @ 2010-07-02  0:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from danglin at gcc dot gnu dot org  2010-07-02 00:12 -------
gfortran.dg/nan_6.f90 fails on hppa2.0w-hp-hpux11:

Executing on host: /test/gnu/gcc/objdir/gcc/testsuite/gfortran/../../gfortran
-B
/test/gnu/gcc/objdir/gcc/testsuite/gfortran/../../
/test/gnu/gcc/gcc/gcc/testsui
te/gfortran.dg/nan_6.f90   -O0   -pedantic-errors 
-B/test/gnu/gcc/objdir/hppa2.
0w-hp-hpux11.11/./libgfortran/.libs
-L/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11
/./libgfortran/.libs
-L/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11/./libgfortran/
.libs -L/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11/./libiberty  -lm   -o
./nan_6
.exe    (timeout = 300)
PASS: gfortran.dg/nan_6.f90  -O0  (test for excess errors)
Setting LD_LIBRARY_PATH to
.:/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11/./libgfo
rtran/.libs:/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11/./libgfortran/.libs:/test
/gnu/gcc/objdir/gcc:.:/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11/./libgfortran/.
libs:/test/gnu/gcc/objdir/hppa2.0w-hp-hpux11.11/./libgfortran/.libs:/test/gnu/gc
c/objdir/gcc
FAIL: gfortran.dg/nan_6.f90  -O0  execution test


Breakpoint 2, MAIN__ ()
    at /test/gnu/gcc/gcc/gcc/testsuite/gfortran.dg/nan_6.f90:89
89      if (.not. isnan(real(z))) call abort()
(gdb) p z
$1 = 0 + 0 * I

(gdb) bt
#0  0x00002d40 in _gfortran_abort ()
    at ../../../gcc/libgfortran/intrinsics/abort.c:32
#1  0x00003f74 in MAIN__ ()
    at /test/gnu/gcc/gcc/gcc/testsuite/gfortran.dg/nan_6.f90:89
#2  0x00004210 in main (argc=<error reading variable>, 
    argv=<error reading variable>)
    at /test/gnu/gcc/gcc/gcc/testsuite/gfortran.dg/nan_6.f90:99


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (13 preceding siblings ...)
  2010-07-02  0:12 ` danglin at gcc dot gnu dot org
@ 2010-07-02  7:10 ` burnus at gcc dot gnu dot org
  2010-07-02 15:19 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-02  7:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from burnus at gcc dot gnu dot org  2010-07-02 07:09 -------
(In reply to comment #14)
> gfortran.dg/nan_6.f90 fails on hppa2.0w-hp-hpux11:
> Breakpoint 2, MAIN__ ()
>     at /test/gnu/gcc/gcc/gcc/testsuite/gfortran.dg/nan_6.f90:89
> 89      if (.not. isnan(real(z))) call abort()
> (gdb) p z
> $1 = 0 + 0 * I

Seemingly hppa2.0w-hp-hpux11's strtod is unable to handle a POSIX conform NAN
of the form "NAN(n-char-sequence_opt)" as the failure occurs for
  '(NAN(0x111),0.0)'
For the relevant quote from POSIX, see comment 4. (John, you could thus
consider to fill a bugreport at HP.)

The simplest solution is to ignore the (...) part - as already done for
formatted I/O and read_real. While the value is in principle usable (by
evaluating the bits), probably no one uses it. Or as POSIX puts it:
"the meaning of the n-char sequences is implementation-defined."

Jerry, John, what do you think?

Untested patch:

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 72016b7..c88edf6 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -1206,10 +1206,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int
length)
          for ( ; c != ')'; c = next_char (dtp))
            if (is_separator (c))
              goto bad;
-           else
-             push_char (dtp, c);

-         push_char (dtp, ')');
          c = next_char (dtp);
          if (is_separator (c))
            unget_char (dtp, c);
diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c
index 873d26c..12aa098 100644
--- a/libgfortran/io/read.c
+++ b/libgfortran/io/read.c
@@ -131,11 +131,10 @@ max_value (int length, int signed_flag)


 /* convert_real()-- Convert a character representation of a floating
- * point number to the machine number.  Returns nonzero if there is a
- * range problem during conversion.  Note: many architectures
- * (e.g. IA-64, HP-PA) require that the storage pointed to by the dest
- * argument is properly aligned for the type in question.  TODO:
- * handle not-a-numbers and infinities.  */
+   point number to the machine number.  Returns nonzero if there is a
+   range problem during conversion.  Note: many architectures
+   (e.g. IA-64, HP-PA) require that the storage pointed to by the dest
+   argument is properly aligned for the type in question.  */

 int
 convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int
length)


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (14 preceding siblings ...)
  2010-07-02  7:10 ` burnus at gcc dot gnu dot org
@ 2010-07-02 15:19 ` jvdelisle at gcc dot gnu dot org
  2010-07-02 19:07 ` burnus at gcc dot gnu dot org
  2010-07-02 21:16 ` jvdelisle at gcc dot gnu dot org
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-07-02 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from jvdelisle at gcc dot gnu dot org  2010-07-02 15:18 -------
I think just ignore (..) .  It seems to add no value at this time and assures
compatibility across platforms.  Your patch is OK.


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (15 preceding siblings ...)
  2010-07-02 15:19 ` jvdelisle at gcc dot gnu dot org
@ 2010-07-02 19:07 ` burnus at gcc dot gnu dot org
  2010-07-02 21:16 ` jvdelisle at gcc dot gnu dot org
  17 siblings, 0 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-02 19:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from burnus at gcc dot gnu dot org  2010-07-02 19:07 -------
Subject: Bug 43298

Author: burnus
Date: Fri Jul  2 19:07:30 2010
New Revision: 161735

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161735
Log:
2010-06-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/43298
        * list_read.c (parse_real): Do not pass (..) on for NAN(..).
        * read.c (convert_real): Fix comment about NAN/INF.


Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c
    trunk/libgfortran/io/read.c


-- 


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


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

* [Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
  2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
                   ` (16 preceding siblings ...)
  2010-07-02 19:07 ` burnus at gcc dot gnu dot org
@ 2010-07-02 21:16 ` jvdelisle at gcc dot gnu dot org
  17 siblings, 0 replies; 19+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-07-02 21:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from jvdelisle at gcc dot gnu dot org  2010-07-02 21:16 -------
Thanks Tobias.  Closing.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2010-07-02 21:16 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-08 21:14 [Bug libfortran/43298] New: fortran library does not read in NaN -Inf or Inf jjcogliati-r1 at yahoo dot com
2010-03-08 21:17 ` [Bug libfortran/43298] " jjcogliati-r1 at yahoo dot com
2010-03-09  2:38 ` jvdelisle at gcc dot gnu dot org
2010-03-09  7:24 ` burnus at gcc dot gnu dot org
2010-03-12 12:31 ` burnus at gcc dot gnu dot org
2010-03-12 17:05 ` burnus at gcc dot gnu dot org
2010-04-26  4:45 ` jvdelisle at gcc dot gnu dot org
2010-06-27 19:46 ` jvdelisle at gcc dot gnu dot org
2010-06-28  9:09 ` burnus at gcc dot gnu dot org
2010-06-28 19:15 ` jvdelisle at gcc dot gnu dot org
2010-06-28 20:05 ` burnus at gcc dot gnu dot org
2010-06-30  1:36 ` jvdelisle at gcc dot gnu dot org
2010-06-30  1:39 ` jvdelisle at gcc dot gnu dot org
2010-06-30  8:06 ` burnus at gcc dot gnu dot org
2010-07-02  0:12 ` danglin at gcc dot gnu dot org
2010-07-02  7:10 ` burnus at gcc dot gnu dot org
2010-07-02 15:19 ` jvdelisle at gcc dot gnu dot org
2010-07-02 19:07 ` burnus at gcc dot gnu dot org
2010-07-02 21:16 ` jvdelisle 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).