From: John David Anglin Date: Mon, 25 Mar 2019 11:48:36 +0000 (+0000) Subject: re PR libfortran/79540 (FAIL: gfortran.dg/fmt_fw_d.f90 -O0 execution test) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b7ca376ae90189fa089aef474e2d0bde0d9aca87;p=gcc.git re PR libfortran/79540 (FAIL: gfortran.dg/fmt_fw_d.f90 -O0 execution test) PR libgfortran/79540 * io/write_float.def (build_float_string): Don't copy digits when ndigits is negative. From-SVN: r269911 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 6ce8b5f9fcf..7e741b3b502 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2019-03-25 John David Anglin + + PR libgfortran/79540 + * io/write_float.def (build_float_string): Don't copy digits when + ndigits is negative. + 2019-03-05 Jakub Jelinek PR libgfortran/89593 diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index 1e2dee89d83..c63db4e77ef 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -620,14 +620,15 @@ build_float_string (st_parameter_dt *dtp, const fnode *f, char *buffer, } /* Set digits after the decimal point, padding with zeros. */ - if (nafter > 0) + if (ndigits >= 0 && nafter > 0) { if (nafter > ndigits) i = ndigits; else i = nafter; - memcpy (put, digits, i); + if (i > 0) + memcpy (put, digits, i); while (i < nafter) put[i++] = '0';