From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 32DCC3858C60; Wed, 26 Jul 2023 20:56:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32DCC3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690404960; bh=kp4rgjp2v2i+AD17oWl32EfARnBKokscDCzyRpfvSL0=; h=From:To:Subject:Date:From; b=Ltf31kY8IiJe3x16w+Lp9hcF92MPzMK7MBDJaiC7MSBfm5sAVaWqGr3Do3TnfJ0HJ IcNgknyYWQOFhVFs+epIM5OM0c7foqD3Mg7mI+e3XLRpqNkkQ2ksUyRqQ7eJxqjk6j /evDlEnX8vv/yR3s8TVC8FGN5sLddxt3gWePyiRs= From: "mysecmailboks at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/110826] New: Fortran array of derived type with a pointer to function with dimensional arguments Date: Wed, 26 Jul 2023 20:55:59 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mysecmailboks 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=3D110826 Bug ID: 110826 Summary: Fortran array of derived type with a pointer to function with dimensional arguments Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mysecmailboks at gmail dot com Target Milestone: --- The following program fails at `func_array(1)%f =3D> zero_state`: ``` program test_func_array implicit none type pp procedure(func_template), pointer, nopass :: f =3D>null() end type pp abstract interface function func_template(state) result(dstate) implicit none real, dimension(:,:), intent(in) :: state real, dimension(size(state,1), size(state,2)) :: dstate end function end interface type(pp) :: func_array(4) real, dimension(4,6) :: state func_array(1)%f =3D> zero_state print*,func_array(1)%f(state) contains function zero_state(state) result(dstate) implicit none real, dimension(:,:), intent(in) :: state real, dimension(size(state,1), size(state,2)) :: dstate dstate =3D 0. end function zero_state end program test_func_array ``` I have tested with various `gfortran` compilers at https://godbolt.org/. The error is roughly the same. Along the lines of: ``` f951: internal compiler error: spec_dimen_size(): Bad dimension 0x75ee87 gfc_internal_error(char const*, ...) ???:0 0x72a016 spec_dimen_size(gfc_array_spec*, int, __mpz_struct (*) [1]) ???:0 0x7d4bcb gfc_expression_rank(gfc_expr*) ???:0 0x7de37b gfc_resolve_code(gfc_code*, gfc_namespace*) ???:0 0x7c7500 gfc_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions. ASM generation compiler returned: 1 f951: internal compiler error: spec_dimen_size(): Bad dimension 0x75ee87 gfc_internal_error(char const*, ...) ???:0 0x72a016 spec_dimen_size(gfc_array_spec*, int, __mpz_struct (*) [1]) ???:0 0x7d4bcb gfc_expression_rank(gfc_expr*) ???:0 0x7de37b gfc_resolve_code(gfc_code*, gfc_namespace*) ???:0 0x7c7500 gfc_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions. Execution build compiler returned: 1 ``` The same error is given even if the dimensional arguments are explicitly defined (as opposed to using `size`). The program works if func_array is a scalar: ``` type(pp) :: func_array real, dimension(4,6) :: state func_array%f =3D> zero_state print*,func_array%f(state) ```=