[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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 0x2d40 in _gfortran_abort () at ../../../gcc/libgfortran/intrinsics/abort.c:32 #1 0x3f74 in MAIN__ () at /test/gnu/gcc/gcc/gcc/testsuite/gfortran.dg/nan_6.f90:89 #2 0x4210 in main (argc=, argv=) at /test/gnu/gcc/gcc/gcc/testsuite/gfortran.dg/nan_6.f90:99 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43298
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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 PR fortran/43298 * list_read.c (parse_real, read_real): Support NAN(alphanum). 2010-06-28 Tobias Burnus 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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|-00-00 00:00:00 |2010-03-09 02:38:33 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43298
[Bug libfortran/43298] fortran library does not read in NaN -Inf or Inf
--- 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