From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A554A3858035; Mon, 28 Nov 2022 10:01:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A554A3858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669629667; bh=P0DqdPRsxveZDSxDAgkoTybfzJgRsLvq99g7I11c0Fo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JfqwAlF20V39iLR+zuVbQJLDadB//JUztwHzQtVlMFF1/t+a0a6MgE25m5b9lRA1o padplKIQTRi2wCEIuJqooovnXugqQlY6p+3RIRI2zzpJHmQcCnqyjf5NlSDjqV7Xk6 p2uZXxOy/YKRiFpmF325KZArCKvIns4h8Egg4zFc= From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291 Date: Mon, 28 Nov 2022 10:01:06 +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: 12.2.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pault 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: attachments.created 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=3D107872 --- Comment #3 from Paul Thomas --- Created attachment 53975 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53975&action=3Dedit Fix for this PR This is a trivial bug. The ICE is occurring in resolve.cc(derived_inaccessi= ble) because derived types with recursive allocatable components have not been allowed for. With the patch, the test below does the right thing. I am tied up with my finalization work at present. If somebody else wishes = to commit the patch, be my guest. With a pointer component, the test runs correctly back to gfortran 7.4.1 20191027. Cheers Paul ! { dg-do run } ! ! Test the fix for PR107872, where an ICE occurred in resolve.cc(derived_inaccessible) ! because derived types with recursive allocatable components were not cate= red for. ! module mod1 type t integer :: data type(t), allocatable :: next contains procedure, private :: write_t generic :: write(formatted) =3D> write_t end type contains recursive subroutine write_t(this, unit, iotype, v_list, iostat, iomsg) class(t), intent(in) :: this integer, intent(in) :: unit character(*), intent(in) :: iotype integer, intent(in) :: v_list(:) integer, intent(out) :: iostat character(*), intent(inout) :: iomsg if (ALLOCATED(this%next)) & write (unit, '(dt)') this%next write (unit, '(i2)') this%data end subroutine end module use mod1 type(t) :: a character (8) :: buffer a%data =3D 1 allocate (a%next) a%next%data =3D 2 allocate (a%next%next) a%next%next%data =3D 3 write (buffer, '(dt)')a deallocate (a%next) if (trim (buffer) .ne. ' 3 2 1') stop 1 end=