From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 26EF6383D8CF; Sun, 20 Nov 2022 00:54:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26EF6383D8CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668905694; bh=7VZdHy+Pe5QcPvrbVPMF0Js8FfweBKlH5IqRzINIX8I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WfCyZagTXdezFaKl7jiMPEW3CIMIgvtsyoWCGnVO8o7HNJ1nqsJ6i7tsCVuHzBzQT jKs20VVMKY5zMGxymClBsuGSJUOZNqfebitYhQRO5BX9e7hmxLXKeb4onk9HCqZfgN 6wsvXmdw8mldO8QB9l6P/b+HERZCLuuTrQdUKS8A= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107753] gfortran returns NaN in complex divisions (x+x*I)/(x+x*I) and (x+x*I)/(x-x*I) Date: Sun, 20 Nov 2022 00:54:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D107753 --- Comment #12 from Steve Kargl = --- On Sat, Nov 19, 2022 at 08:14:01PM +0000, anlauf at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107753 >=20 > --- Comment #11 from anlauf at gcc dot gnu.org --- > (In reply to Weslley da Silva Pereira from comment #7) > > More data for the discussion: > > 1. In a Ubuntu 18.04.5 LTS, using GNU Fortran 7.5.0, I tested optimizat= ion > > flags `-O` but still reproduce the wrong result for complex divisions w= ith > > huge numbers. See >=20 > It is possible that gfortran's dependence on optimization level depends > on the version. If one wants to test run-time behavior and avoid > compile-time simplification, it may be helpful to add: >=20 > volatile :: x, y, z >=20 > I then get consistent results for -O0 / -O1. >=20 The optimization level is irrelevant. gfortran unilaterally uses -fcx-fortran-rules, and there is no way to disable this option to user the slower, but stricter, evaluation. One will always get complex division computed by a+ib a + b(d/c) b - a(d/c)=20 ---- =3D ---------- + i ------------ |c| > |d| c+id c + d(d/c) c + d(d/c) and similar for |d| > |c|. There are a few problems with this. d/c can trigger an invalid underflow exception. If d =3D=3D c, you then have numerators of a + b and b - a, you can get a invalid overflow for a =3D huge() and b > 1e291_8.=