From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF159384A033; Thu, 11 Jun 2020 17:14:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF159384A033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591895664; bh=G6qBJaqst/1UJ/9epQACN9Xb5EQGH6hWIp6gWONQLiw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=x52RW1wDcyIXpyhdoolrfo7QVPnW2cxmO2mp0Bj1miNVKZbA3i+AimIHmei1MkhKQ SCC+iG1S3dV55oe17aypeRIqvTOd9tG/7A/sBC9Qjh6nsrs3rKAoxAoLkJehvIFkZX drDtVeEj5i3/8wJ912jFVEYIwfL+fUaY9tcmvUHY= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/95640] gfortran ieee_selected_real_kind returns 10 Date: Thu, 11 Jun 2020 17:14:24 +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: 9.3.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW 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 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: Thu, 11 Jun 2020 17:14:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95640 --- Comment #8 from Steve Kargl -= -- On Thu, Jun 11, 2020 at 04:21:25PM +0000, longb at cray dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95640 >=20 > --- Comment #6 from Bill Long --- > (In reply to kargl from comment #3) > > (In reply to Bill Long from comment #0) > > > > cat test.f90 > >=20=20 > > > Gfortran:=20 > > >=20 > > > > module swap PrgEnv-intel PrgEnv-gnu > > > > gfortran test.f90 > > > > ./a.out > > > selected_real_kind(16) =3D 10 > > > ieee_selected_real_kind(16) =3D 10 > > >=20 > > > The output from gfortran is problematic because ieee_selected_real_ki= nd > > > should not return 10. If the users want KIND=3D10 (i.e. the > > > Intel-proprietary 80-bit x87 floats), then they need to use > > > selected_real_kind and not the IEEE version. > >=20 > > IEEE-754 permits the extended double type (See 3.7 Extended and > > extendable precisions). I do not see in the Fortran standard that > > the output from ieee_seleted_real_kind must select binary32, > > binary64, or binary128. > >=20 > > That said, ieee_selected_real_kind is completely broken. > > See PR69101. I used to have patch that fixed this PR, > > but never got around to committing it. The patch attached > > in 69101 is not correct. >=20 >=20 > The description in the Fortran standard for IEEE_SELECTED_REAL_KIND inclu= des > "The result has a value equal to a value of the kind type parameter of an > ISO/IEC/IEEE 60559:2011 floating-point format..." This, in practice, amou= nts to > binary32, 64, 128 for RADIX=3D2 (the default). The 80-bit x87 format is = not part > of the quoted IEEE standard. >=20 IEEE-754 calls binary32, 64, 128 the basic formats (Sec. 3, p. 6): Five basic formats are defined in this clause: Three binary formats, with encodings in lengths of 32, 64, and 128 bits. Two decimal formats, with encodings in lengths of 64 and 128 bits. Additional arithmetic formats are recommended for extending these basic formats (see 3.7). If J3 really intended that IEEE_SELECTED_REAL_KIND return a kind for one of IEEE-754 basic formats, then it ought to say that. Looks like a defect in the Fortran standard. If one looks into 3.7 (p. 14), it further recommends Language standards should define mechanisms supporting extendable precision for each supported radix.=