From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 596543858D37; Mon, 10 Oct 2022 19:28:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 596543858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665430114; bh=ryY5ub7ymVrBbNNvRMGwdTC+XOxnxPwCnZh45cnvu7Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eVUH20D68ou84mc/SdcTdugKLOVvYZCo3bxgUH2IEZQwO6sUH+m55h/tSGPUpDbh2 /4evIIzPnokedWII7f5mFP7qokMd2fRxhy8DWX/wz50zHGqX93VGF/y8l7/tI7V4j3 jtp0Y58r3JdKEopB01hMRCfddjU4jQiFoyfkeuMc= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/105371] The result of the merge function is different when it's type of parameters is the extensions type of derived type Date: Mon, 10 Oct 2022 19:28:33 +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: 11.3.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf 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: everconfirmed cf_reconfirmed_on bug_status keywords cc 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=3D105371 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2022-10-10 Status|UNCONFIRMED |NEW Keywords| |wrong-code CC| |anlauf at gcc dot gnu.org --- Comment #8 from anlauf at gcc dot gnu.org --- (In reply to anlauf from comment #4) > Thing is, I have to find a compiler that gives the result the reporter > expects. Update: the NAG compiler 7.1 seems to be the only compiler that behaves as expected by the user. The somewhat modified testcase shows that not only simplification of MERGE, but also the generated code behaves inconsistently: program p implicit none type t integer :: c end type type, extends (t) :: t2 integer :: c2 end type class(t), allocatable :: x, y, r integer :: i =3D 1 x =3D t2(1,-1) y =3D t2(2,-2) r =3D x call check_type() r =3D merge (x, x, i =3D=3D 1) call check_type () r =3D merge (y, y, i =3D=3D 2) call check_type () r =3D merge (x, y, i =3D=3D 2) call check_type () contains subroutine check_type () select type (z =3D> r) type is (t) print *, "type is (t) :", z% c type is (t2) print *, "type is (t2):", z% c, z% c2 end select end subroutine end program p NAG 7.1 prints: type is (t2): 1 -1 type is (t2): 1 -1 type is (t2): 2 -2 type is (t2): 2 -2 Current gfortran: type is (t2): 1 -1 type is (t) : 1 type is (t) : 2 type is (t2): 2 -2 As MERGE is expanded inline, I was hoping to understand what happens here, but a first look at the dump-tree looked strange for the second and third case. Needs further investigation.=