From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 290523851142; Wed, 24 Aug 2022 17:38:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 290523851142 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661362703; bh=cT9GilHEWZfVE0KrH2xKYaTyTCos90nynKSdReJbESY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BHih06XtPnnFDndkEe3SneBnEejoR3+TOp6rKXxcDbEQFwWx5nSY0kfuuLxYvlAep ooucF9sIR4iqfqSw8SvPZe05QEoODpjtIu/nvqO85afHIyTiUOpBNNsQG868B4f7Cu gnbvKsYvsU2WNB3e0p4QCAUpfbrl0VGF/o3WbMdg= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106731] ICE on automatic array of derived type with DTIO Date: Wed, 24 Aug 2022 17:38:22 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl 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: 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=3D106731 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #3 from kargl at gcc dot gnu.org --- (In reply to federico from comment #0) > A derived type that has user-defined I/O causes ICE on all gfortran versi= ons > 7 to 12.1.0, whenever it's being used as an automatic object. >=20 > The error is at=20 >=20 >=20 > 63 | type(t) :: automatic(n) > | 1 > internal compiler error: in gfc_trans_auto_array_allocation, at > fortran/trans-array.cc:6617 >=20 > This does not happen if the derived type is allocated. >=20 > Here's the simplest example:=20 >=20 > module causes_ice > implicit none >=20 > type :: t > real(8) :: x > contains > procedure, private :: write_formatted > generic :: write(formatted) =3D> write_formatted > end type t >=20 > contains >=20 > subroutine write_formatted(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 > write(unit, '(a)', iostat=3Diostat, iomsg=3Diomsg) 'dummy' > end subroutine write_formatted >=20 > end module causes_ice >=20 > module use_t > use causes_ice > implicit none >=20 > public :: automatic_alloc >=20 > contains >=20 > subroutine automatic_alloc(n) > integer, intent(in) :: n >=20 > ! Automatic array: ICE! > type(t) :: automatic(n) >=20 > ! Allocatable: works > type(t), allocatable :: alloc(:) > allocate(alloc(n)) >=20 > ! Do anything > print *, 'n=3D',n,automatic(n)%x >=20 > end subroutine automatic_alloc >=20 > end module use_t >=20 > program test > use use_t > call automatic_alloc(1) > end program test >=20 > I could find other DTIO-related bugs, but none seemed related with the > allocation type. You're hitting an assert() in trans-array.cc. It's unclear to me why the assert() is there. If it is commented out, the code compiles and executes. % git diff gcc/fortran/trans-array.cc | cat diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 05134952db4..c5916aeee53 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -6614,7 +6614,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbo= l * sym, type =3D TREE_TYPE (type); gcc_assert (!sym->attr.use_assoc); - gcc_assert (!TREE_STATIC (decl)); +// gcc_assert (!TREE_STATIC (decl)); gcc_assert (!sym->module); if (sym->ts.type =3D=3D BT_CHARACTER=