------- 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

Reply via email to