From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D3A873858D37; Mon, 29 Aug 2022 10:02:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3A873858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661767327; bh=WaWmrHxt+iBpLwQBC+czsJkiznULFz54mhZ1AsfhF6U=; h=From:To:Subject:Date:From; b=fAKvo884oANyigsXZaSAMcWo77lPW029VJyxQFEvwFxk3QbeO/J1g2OL79JWUyyqc 6Mkult5QpOIHscYtKxxupq4v28hzcbdevF5tnTAKguksZ2hqElxfgIHwXmkpHlMvK3 tnfOxg5ylCCSx+AvTkvVndC7f1r4nrCTAMa62uIw= From: "federico.perini at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106771] New: [OOP] ICE with PACK intrinsic, in gfc_conv_expr_descriptor, at fortran/trans-array.c:7328 Date: Mon, 29 Aug 2022 10:02:07 +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.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: federico.perini 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106771 Bug ID: 106771 Summary: [OOP] ICE with PACK intrinsic, in gfc_conv_expr_descriptor, at fortran/trans-array.c:7328 Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: federico.perini at gmail dot com Target Milestone: --- I'm getting an ICE using the PACK intrinsic from within a polymorphic entit= y. There are several similar bugs reported, but none seems to address PACK, so= I'm opening a new ticket. BTW: I've tested it on godbolt (try here: https://godbolt.org/z/cnj6PzqKz) And it looks like:=20 WORKS on: 10.4.0, 11 (all), 12 (all) ICE on: 4.9, 5-8 (all), 9 (all), 10.1, 10.2, 10.3 The mask is created from a polymorphic elemental function on the object Here's a minimal example:=20 module test implicit none type::t integer, allocatable :: iloc(:) contains=20 procedure :: is_active =3D> isa procedure :: list2loc =3D> myfun_poly end type t contains elemental logical function isa(this,i) class(t), intent(in) :: this integer, intent(in) :: i if (i>0 .and. i<=3Dmerge(size(this%iloc),0,allocated(this%iloc))) th= en=20 isa =3D this%iloc(i)>0 else isa =3D .false. endif=20=20 end function isa ! internal compiler error: in gfc_conv_expr_descriptor, at fortran/trans-array.c:7328 function myfun_poly(this,IDs) result (ilocs) class(t), intent(in) :: this integer, intent(in) :: IDs(:) integer, allocatable :: ilocs(:) if (size(IDs)<=3D0) then allocate(ilocs(0)) else ilocs =3D pack(this%iloc(IDs),this%is_active(ilocs)) endif end function myfun_poly ! WORKS function myfun(this,IDs) result (ilocs) type(t), intent(in) :: this integer, intent(in) :: IDs(:) integer, allocatable :: ilocs(:) if (size(IDs)<=3D0) then allocate(ilocs(0)) else ilocs =3D pack(this%iloc(IDs),this%is_active(ilocs)) endif end function myfun end module test=20=20=20=20 program testp use test implicit none type(t) :: a integer :: rnd(100) real :: x(100) integer, allocatable :: list(:) call random_number(x); rnd =3D ceiling(x*100) ! Works list =3D myfun(a,rnd) ! ICE list =3D a%list2loc(rnd) print *, 'list=3D',list end program testp Hope this helps, federico=