diff options
Diffstat (limited to 'libgfortran/io/read.c')
-rw-r--r-- | libgfortran/io/read.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c index d7d5c41..e35b1a0 100644 --- a/libgfortran/io/read.c +++ b/libgfortran/io/read.c @@ -129,6 +129,24 @@ int convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int length) { char *endptr = NULL; + int round_mode, old_round_mode; + + switch (dtp->u.p.current_unit->round_status) + { + case ROUND_COMPATIBLE: + /* FIXME: As NEAREST but round away from zero for a tie. */ + case ROUND_UNSPECIFIED: + /* Should not occur. */ + case ROUND_PROCDEFINED: + round_mode = ROUND_NEAREST; + break; + default: + round_mode = dtp->u.p.current_unit->round_status; + break; + } + + old_round_mode = get_fpu_rounding_mode(); + set_fpu_rounding_mode (round_mode); switch (length) { @@ -167,6 +185,8 @@ convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int length) internal_error (&dtp->common, "Unsupported real kind during IO"); } + set_fpu_rounding_mode (old_round_mode); + if (buffer == endptr) { generate_error (&dtp->common, LIBERROR_READ_VALUE, |