re PR fortran/24096 (huge() returns infinity for long doubles)
authorAlan Modra <amodra@bigpond.net.au>
Tue, 15 Nov 2005 20:33:48 +0000 (20:33 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Tue, 15 Nov 2005 20:33:48 +0000 (07:03 +1030)
PR fortran/24096
* trans-types.c (gfc_init_kinds): Use one less for max_exponent
of IBM extended double format.

From-SVN: r107041

gcc/fortran/ChangeLog
gcc/fortran/trans-types.c

index 0a24084..7e22961 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-16  Alan Modra  <amodra@bigpond.net.au>
+
+       PR fortran/24096
+       * trans-types.c (gfc_init_kinds): Use one less for max_exponent
+       of IBM extended double format.
+
 2005-11-13  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        * intrinsic.c (add_functions): Add COMPLEX, FTELL, FGETC, FGET,
index 81a90f1..6aaf81a 100644 (file)
@@ -192,6 +192,15 @@ gfc_init_kinds (void)
       gfc_real_kinds[r_index].digits = fmt->p;
       gfc_real_kinds[r_index].min_exponent = fmt->emin;
       gfc_real_kinds[r_index].max_exponent = fmt->emax;
+      if (fmt->pnan < fmt->p)
+       /* This is an IBM extended double format (or the MIPS variant)
+          made up of two IEEE doubles.  The value of the long double is
+          the sum of the values of the two parts.  The most significant
+          part is required to be the value of the long double rounded
+          to the nearest double.  If we use emax of 1024 then we can't
+          represent huge(x) = (1 - b**(-p)) * b**(emax-1) * b, because
+          rounding will make the most significant part overflow.  */
+       gfc_real_kinds[r_index].max_exponent = fmt->emax - 1;
       gfc_real_kinds[r_index].mode_precision = GET_MODE_PRECISION (mode);
       r_index += 1;
     }