From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 52FD8396EC4F; Tue, 8 Dec 2020 14:44:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52FD8396EC4F From: "pozar at ecs dot umass.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/98201] New: CSQRT function gives bad resuts at runtime Date: Tue, 08 Dec 2020 14:44:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 9.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pozar at ecs dot umass.edu X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2020 14:44:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98201 Bug ID: 98201 Summary: CSQRT function gives bad resuts at runtime Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: pozar at ecs dot umass.edu Target Milestone: --- I am running mingw gfortran 9.2.0 on Windows 7, and have a problem with res= ults from the CSQRT function during runtime. Sample code below, with results. Starting with a complex argument having increasingly large real part, and a relatively small imaginary part, csqrt initially gives a correct result (as tested by squaring the result from CSQRT). But the second row shows some significant error, and later rows show 'Infinity' for the imaginary part. (using sq =3D z**.5 gives correct results) F95 CODE; ! test CSQRT complex z, sq write(6,*) " Argument SquareRoot SR squared" do n=3D1,9 z=3D-10.**n+(0.,.1) sq=3Dcsqrt(z) write(*,1) z, sq, sq*sq end do 1 format(3("(",e10.4,2x,e10.4,")",3x)) pause RESULTS: Argument SquareRoot SR squared (-.1000E+02 0.1000E+00) (0.1581E-01 0.3163E+01) (-.1001E+02 0.1000E+= 00) (-.1000E+03 0.1000E+00) (0.5167E-02 0.9676E+01) (-.9362E+02 0.1000E+= 00) (-.1000E+04 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) (-.1000E+05 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) (-.1000E+06 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) (-.1000E+07 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) (-.1000E+08 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) (-.1000E+09 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) (-.1000E+10 0.1000E+00) (0.0000E+00 Infinity) ( -Infinity N= aN) PAUSE=