summaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2019-03-25 11:48:36 +0000
committerJohn David Anglin <danglin@gcc.gnu.org>2019-03-25 11:48:36 +0000
commitb7ca376ae90189fa089aef474e2d0bde0d9aca87 (patch)
tree2c5faa78b99ca3964c50ff3d1eaeb2d9c166c790 /libgfortran/io
parenta260f369382876ca5575316b9a761057225e2ff0 (diff)
downloadgcc-b7ca376ae90189fa089aef474e2d0bde0d9aca87.tar.gz
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
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/write_float.def5
1 files changed, 3 insertions, 2 deletions
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';