https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34678
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |105105 --- Comment #47 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (In reply to Thomas Koenig from comment #46) > Fortran gets this right: ... but only by accident. This test case shows that it doesn't: $ cat y.f90 module y implicit none integer, parameter :: wp = selected_real_kind(15) contains subroutine foo(a,b,c) use ieee_arithmetic real(kind=wp), dimension(4), intent(out) :: a real(kind=wp), intent(in) :: b, c type (ieee_round_type), dimension(4), parameter :: mode = & [ieee_nearest, ieee_to_zero, ieee_up, ieee_down] call ieee_set_rounding_mode (mode(1)) a(1) = b + c call ieee_set_rounding_mode (mode(2)) a(2) = b + c call ieee_set_rounding_mode (mode(3)) a(3) = b + c call ieee_set_rounding_mode (mode(4)) a(4) = b + c end subroutine foo end module y program main use y real(kind=wp), dimension(4) :: a call foo(a, 0.1_wp, 0.2_wp) print *,a end program main $ gfortran -O y.f90 && ./a.out 0.30000000000000004 0.30000000000000004 0.30000000000000004 0.30000000000000004 $ gfortran y.f90 && ./a.out 0.30000000000000004 0.29999999999999999 0.30000000000000004 0.29999999999999999 Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105105 [Bug 105105] [Meta] Fortran IEEE support