From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 52C8F3858CDA; Fri, 6 Jan 2023 22:14:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52C8F3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673043267; bh=bWrddnmgOawsQb+9/7Vjg94uOWW/FsoHsYDBDE7d63Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RxHl8h5zCOouedsAnzT1DXHAXf97/R1C/AIMS2ZY2hNTGWnGRWV2401NDIjCWpw7x kjmz1ZnmFCsfmzfhHvTIODzDMgnFP1RNqk3cz+awwRH1lAjqPTcV1UUSf6vGINzWPU rNM9rleAlgMQi2oWhlGtaaoKPl9VPxcHtgTnCyhk= From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/34678] Optimization generates incorrect code with -frounding-math option (#pragma STDC FENV_ACCESS not implemented) Date: Fri, 06 Jan 2023 22:14:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: blocked Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D34678 Thomas Koenig changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |105105 --- Comment #47 from Thomas Koenig --- (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 =3D selected_real_kind(15) contains subroutine foo(a,b,c) use ieee_arithmetic real(kind=3Dwp), dimension(4), intent(out) :: a real(kind=3Dwp), intent(in) :: b, c type (ieee_round_type), dimension(4), parameter :: mode =3D & [ieee_nearest, ieee_to_zero, ieee_up, ieee_down] call ieee_set_rounding_mode (mode(1)) a(1) =3D b + c call ieee_set_rounding_mode (mode(2)) a(2) =3D b + c call ieee_set_rounding_mode (mode(3)) a(3) =3D b + c call ieee_set_rounding_mode (mode(4)) a(4) =3D b + c end subroutine foo end module y program main use y real(kind=3Dwp), 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= =20=20=20=20=20=20 0.30000000000000004=20=20=20=20=20 $ gfortran y.f90 && ./a.out 0.30000000000000004 0.29999999999999999 0.30000000000000004= =20=20=20=20=20=20 0.29999999999999999 Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105105 [Bug 105105] [Meta] Fortran IEEE support=