From: John David Anglin Date: Wed, 17 Apr 2019 00:22:23 +0000 (+0000) Subject: re PR libfortran/79540 (FAIL: gfortran.dg/fmt_fw_d.f90 -O0 execution test) X-Git-Tag: releases/gcc-7.5.0~481 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba3209c010f3cda5e022387d7e788e1867f21e75;p=thirdparty%2Fgcc.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: r270402 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 219b1ffd89ad..5ead90f9e4c2 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,12 @@ +2019-04-16 John David Anglin + + Backport from mainline + 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-02-03 Uroš Bizjak PR libfortran/88678 diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index b4971fd335e8..e303f7d73a85 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';