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
This commit is contained in:
John David Anglin 2019-04-17 00:22:23 +00:00
parent 300e391440
commit ba3209c010
2 changed files with 12 additions and 2 deletions

View File

@ -1,3 +1,12 @@
2019-04-16 John David Anglin <danglin@gcc.gnu.org>
Backport from mainline
2019-03-25 John David Anglin <danglin@gcc.gnu.org>
PR libgfortran/79540
* io/write_float.def (build_float_string): Don't copy digits when
ndigits is negative.
2019-02-03 Uroš Bizjak <ubizjak@gmail.com>
PR libfortran/88678

View File

@ -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';