From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 892903858C5F; Wed, 15 Mar 2023 19:56:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 892903858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678910208; bh=NePwEd6gzelVafKFcOj3rUXnVfZiBX5v+naR/LuQJNI=; h=From:To:Subject:Date:From; b=lXtqymMvOJ7xk2cPF5+qfFyeCZgK3E3usIxQll5Grt63OC219Go5SPykE5i5Wl/hg 9qWor/cT0oYXc3T1+Ki1+E2g9mfGcwWCEIK/F0Tml1U3K4aKmLRP7jy9O5hZFfI7dv mCNalI1pXKN4QiguU+Y2YqXw/p0LBGQrtQgGbYLw= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109148] New: ICE with explicit-/assumed-size arrays and CLASS Date: Wed, 15 Mar 2023 19:56:48 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org 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=3D109148 Bug ID: 109148 Summary: ICE with explicit-/assumed-size arrays and CLASS Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gcc dot gnu.org Target Milestone: --- The following is a spin-off from pr58331. Consider: module mymod implicit none type t integer :: i end type t contains subroutine mysub(a, n) integer, intent(in) :: n class(*), intent(in) :: a(n) select type(a) type is(integer) print *,'a is integer' print *, "n=3D", n, ' a=3D', a class default print *,'a is unsupported type' stop 1 end select end subroutine sub_t(a, n) integer, intent(in) :: n class(t), intent(in) :: a(n) select type(a) class is(t) print *,'a is type(t)' print *, "n=3D", n, ' a=3D', a%i class default print *,'a is unsupported type' stop 1 end select end ! Unlimited polymorphic variant subroutine sub_star(a, n) integer, intent(in) :: n class(*), intent(in) :: a(n) select type(a) type is(integer) print *,'a is integer' print *, "n=3D", n, ' a=3D', a class is(t) print *,'a is type(t)' print *, "n=3D", n, ' a=3D', a%i class default print *,'a is unsupported type' stop 1 end select end end program p use mymod implicit none integer :: b(2,2) =3D reshape([21, 22, 23, 24], [2,2]) type(t) :: x(2,2) =3D reshape([t(5), t(6),t(7),t(8)], [2,2]) type(t) :: y(4) =3D [t(15), t(16),t(17),t(18)] class(t), allocatable :: w(:) class(t), allocatable :: z(:,:) allocate (z, source=3Dx) allocate (w, source=3Dy) call mysub (b,4) ! see pr58331 ! call sub_t (b,4) ! correctly rejected call sub_t (y,4) call sub_t (z,4) ! OK (although wrong code with crayftn 14.0) call sub_t (w,4) ! OK call sub_star(b,4) ! ok call sub_star(y,4) ! ok ! call sub_star(x,4) ! ICE in gfc_conv_derived_to_class ! call sub_t (x,4) ! ICE in gfc_conv_derived_to_class end This compiles and seems to work fine with r13-6698. But uncommenting one of the last two calls produces: class_dummy_11.f90:76:54: 76 | call sub_star(x,4) ! ICE in gfc_conv_derived_to_class | 1 internal compiler error: in gfc_conv_derived_to_class, at fortran/trans-expr.cc:831 0x70cdc0 gfc_conv_derived_to_class(gfc_se*, gfc_expr*, gfc_typespec, tree_node*, bool, bool, tree_node**) ../../gcc-trunk/gcc/fortran/trans-expr.cc:831 0xa2dcdd gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*, gfc_expr*, vec*) ../../gcc-trunk/gcc/fortran/trans-expr.cc:6223 0xa81f22 gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool) ../../gcc-trunk/gcc/fortran/trans-stmt.cc:424 0x9ee9d3 trans_code ../../gcc-trunk/gcc/fortran/trans.cc:2018 0xa20eb1 gfc_generate_function_code(gfc_namespace*) ../../gcc-trunk/gcc/fortran/trans-decl.cc:7704 0x99a587 translate_all_program_units ../../gcc-trunk/gcc/fortran/parse.cc:6720 0x99a587 gfc_parse_file() ../../gcc-trunk/gcc/fortran/parse.cc:7026 0x9eb4df gfc_be_parse_file ../../gcc-trunk/gcc/fortran/f95-lang.cc:229 The code seems to work with Nvidia 23.1, works mostly with Crayftn 14.0, but fails at runtime with Intel 2021.8.=