From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A9F9E3850410; Wed, 6 Jan 2021 19:04:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9F9E3850410 From: "davidhneill at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/98573] New: Dynamic type lost on assignment Date: Wed, 06 Jan 2021 19:04:54 +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.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: davidhneill at gmail dot com 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 attachments.created 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: Wed, 06 Jan 2021 19:04:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98573 Bug ID: 98573 Summary: Dynamic type lost on assignment Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: davidhneill at gmail dot com Target Milestone: --- Created attachment 49904 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49904&action=3Dedit Minimal reproducer In the following example, the dynamic type of an unlimited polymorphic arra= y is lost on an assignment but conserved (as expected) on a sourced allocation. This happens in all versions I've tried: 7.5.0, 8.4.0, 9.3.0, 10.2.0 My system is Ubuntu 20.04 on Intel hardware with all gfortran versions installed directly from the Ubuntu repositories. $ cat type_lost.f90 module foo type, public:: box class(*), allocatable :: val(:) end type contains subroutine store1(this, val) class(box), intent(out) :: this class(*), intent(in) :: val(:) this%val =3D val end subroutine store1 subroutine store2(this, val) class(box), intent(out) :: this class(*), intent(in) :: val(:) allocate(this%val, source=3Dval) end subroutine store2 subroutine vector_type(val) class(*), intent(in) :: val(:) select type (val) type is (integer) print '("INTEGER")' class default print '("OTHER")' end select end subroutine vector_type end module foo program prog use foo type(box) :: b call store1(b, [1, 2, 3]) call vector_type(b%val) ! OTHER call store2(b, [1, 2, 3]) call vector_type(b%val) ! INTEGER end program $ gfortran -g -Wall -Wextra minimal.f90 $ ./a.out OTHER INTEGER=