With the following fortran format from the gfortran.dg/fmt_fw_d.f90 test

print '(f2.1)',    100.000000
end

The computed number of digits is negative.  On hppa-hpux, this causes a stack 
overflow
in memcpy.  The attached change skips the copy when ndigits is not positive.  
We also only
fill put with nulls when i in non negative.  This fixes the testcase with no 
regressions.

Committed to trunk.

Dave
-- 
John David Anglin  dave.ang...@bell.net

Index: io/write_float.def
===================================================================
--- io/write_float.def  (revision 269890)
+++ io/write_float.def  (working copy)
@@ -620,7 +620,7 @@
     }

   /* Set digits after the decimal point, padding with zeros.  */
-  if (nafter > 0)
+  if (ndigits >= 0 && nafter > 0)
     {
       if (nafter > ndigits)
        i = ndigits;
@@ -627,7 +627,8 @@
       else
        i = nafter;

-      memcpy (put, digits, i);
+      if (i > 0)
+       memcpy (put, digits, i);
       while (i < nafter)
        put[i++] = '0';


Reply via email to