From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CF4DA39DC4CB; Thu, 4 Mar 2021 14:01:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF4DA39DC4CB From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99355] -freal-X-real-Y -freal-Z-real-X promotes Z to Y Date: Thu, 04 Mar 2021 14:01:18 +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: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: REOPENED 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: 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, 04 Mar 2021 14:01:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99355 --- Comment #11 from Tobias Burnus --- (In reply to Dominique d'Humieres from comment #8) > r11-7501 changed the output of the test in comment O, is this expected? (In reply to Dominique d'Humieres from comment #10) > % gfc pr57871.f90 I am slightly confused. Do you mean the output for this PR's comment 0 has changed =E2=80=93 or the result for the testcase in PR 57871 comment 0? > % ./a.out > kind(1.0_p1) 4 precision(1.0_p1) 6 > kind(1.0_dp) 8 precision(1.0_dp) 15 Using PR 57871 comment 0, I get exactly the same output as you have with bo= th gfortran and ifort. * * * > So without option kind(1.0_p1) is 4, should not it be converted to 16 with > -freal-4-real-16? Currently, the code handles: 1.0 =3D default-kind real 1.0d0 =3D default-double-precision-kind real =E2=86=92 promote And real :: A =E2=86=92 default-kind real double precision :: B =E2=86=92 default-double-precision real real* :: C =E2=86=92 convert real(kind=3D :: D =E2=86=92 convert The question is what to do about: 1.0_ * * * However, we cannot completely avoid ambiguity as for -freal-4-real-8 freal-8-real-16 integer, parameter :: k1 =3D kind(1.0) =E2=86=92 8 real(kind=3Dk1) :: var =E2=86=92 kind(8) =E2=86=92 16 real(kind=3D4) :: var =E2=86=92 kind(4) =E2=86=92 8 But some issues are unavoidable and all -freal-*-real-* flags should be avoided, if possible. * * * Seems as if we need to handle in match_real_constant the case default-real-= kind separately from _kind value specified. Untested: --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -666,6 +666,25 @@ done: if (kind =3D=3D -1) goto cleanup; + if (kind =3D=3D 4) + { + if (flag_real4_kind =3D=3D 8) + kind =3D 8; + if (flag_real4_kind =3D=3D 10) + kind =3D 10; + if (flag_real4_kind =3D=3D 16) + kind =3D 16; + } + else if (kind =3D=3D 8) + { + if (flag_real8_kind =3D=3D 4) + kind =3D 4; + if (flag_real8_kind =3D=3D 10) + kind =3D 10; + if (flag_real8_kind =3D=3D 16) + kind =3D 16; + } + switch (exp_char) { case 'd':=