https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123071

            Bug ID: 123071
           Summary: [PDT] ICE on invoking parent's type-bound function
                    with PDT result
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at archaeologic dot codes
  Target Milestone: ---

$ cat reproducer.f90 
module neural_network_m
  implicit none

  type tensor_t(k)
    integer, kind :: k = kind(1.)
  end type

  type neural_network_t
  contains
    procedure map_tensor
  end type

  interface

    module function map_tensor(self)
      implicit none
      class(neural_network_t) self
      type(tensor_t) map_tensor
    end function

  end interface

end module

  use neural_network_m
  implicit none

  type, extends(neural_network_t) ::  trainable_network_t
  end type

contains

  subroutine foo(self)
    class(trainable_network_t) self
    type(tensor_t) mapped_tensor
    mapped_tensor = self%map_tensor()
  end subroutine

end

$ gfortran -c reproducer.f90 
reproducer.f90:37:16:

   37 |   end subroutine
      |                1
internal compiler error: tree check: did not expect class ‘type’, have ‘type’
(boolean_type) in append_to_statement_list, at tree-iterator.cc:95
0x264824b internal_error(char const*, ...)
        ../../trunk/gcc/diagnostic-global-context.cc:787
0x91328b tree_not_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../trunk/gcc/tree.cc:9287
0x8b66d8 non_type_check(tree_node*, char const*, int, char const*)
        ../../trunk/gcc/tree.h:3957
0x8b66d8 append_to_statement_list(tree_node*, tree_node**)
        ../../trunk/gcc/tree-iterator.cc:95
0xb57407 add_expr_to_chain
        ../../trunk/gcc/fortran/trans.cc:2261
0xbaccc7 gfc_conv_expr_val(gfc_se*, gfc_expr*)
        ../../trunk/gcc/fortran/trans-expr.cc:10616
0xbaccc7 gfc_conv_expr_val(gfc_se*, gfc_expr*)
        ../../trunk/gcc/fortran/trans-expr.cc:10607
0xbace24 gfc_conv_expr_type(gfc_se*, gfc_expr*, tree_node*)
        ../../trunk/gcc/fortran/trans-expr.cc:10626
0xb70032 structure_alloc_comps
        ../../trunk/gcc/fortran/trans-array.cc:11129
0xb71e78 gfc_allocate_pdt_comp(gfc_symbol*, tree_node*, int,
gfc_actual_arglist*)
        ../../trunk/gcc/fortran/trans-array.cc:11568
0xb8fa8d gfc_trans_deferred_vars(gfc_symbol*, gfc_wrapped_block*)
        ../../trunk/gcc/fortran/trans-decl.cc:5005
0xb924f2 gfc_generate_function_code(gfc_namespace*)
        ../../trunk/gcc/fortran/trans-decl.cc:8306
0xaf69fe translate_all_program_units
        ../../trunk/gcc/fortran/parse.cc:7572
0xaf69fe gfc_parse_file()
        ../../trunk/gcc/fortran/parse.cc:7902
0xb54913 gfc_be_parse_file
        ../../trunk/gcc/fortran/f95-lang.cc:247
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ gfortran --version
GNU Fortran (GCC) 16.0.0 20251203 (experimental)
  • [Bug fortran/123071] New: [P... damian at archaeologic dot codes via Gcc-bugs

Reply via email to