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

--- Comment #4 from Andrew Benson <abensonca at gcc dot gnu.org> ---
A possibly related case:

module tm

  type :: st
  end type st

  type :: resourceManager
     class  (*), pointer :: resource => null()
     integer   , pointer :: counter  => null()
  end type resourceManager

  interface resourceManager
     module procedure resourceManager
  end interface

  type :: wrap
     type(st), pointer :: obj => null()
     type(resourceManager) :: manager
  end type wrap

  interface wrap
     module procedure wrapConstructN
  end interface

contains

  function resourceManagerConstructor(resource) result(self)
    implicit none
    type(resourceManager) :: self
    class(*), intent(in   ), pointer :: resource

    self%resource => resource
    allocate(self%counter)
    self%counter=1
    return
  end function resourceManagerConstructor

  function wrapConstructN(i) result(self)
    implicit none
    type(wrap) :: self
    integer, intent(in   ) :: i
    type(st), pointer :: st_

    allocate(self%obj)
    self%obj=st()
    self%manager=resourceManager(self%obj)
    return
  end function wrapConstructN

end module tm

$ gfortran -c bug.F90 -o bug -g
bug.F90:45:42:

   45 |     self%manager=resourceManager(self%obj)
      |                                          1
internal compiler error: in fold_convert_loc, at fold-const.cc:2627
0x770b18 fold_convert_loc(unsigned int, tree_node*, tree_node*)
        ../../gcc-git-unpatched/gcc/fold-const.cc:2627
0xa65649 gfc_trans_subcomponent_assign
        ../../gcc-git-unpatched/gcc/fortran/trans-expr.cc:9053
0xa667c9 gfc_trans_structure_assign(tree_node*, gfc_expr*, bool, bool)
        ../../gcc-git-unpatched/gcc/fortran/trans-expr.cc:9246
0xa67531 gfc_conv_structure(gfc_se*, gfc_expr*, int)
        ../../gcc-git-unpatched/gcc/fortran/trans-expr.cc:9313
0xa6ae35 gfc_trans_assignment_1
        ../../gcc-git-unpatched/gcc/fortran/trans-expr.cc:11742
0xa1b307 trans_code
        ../../gcc-git-unpatched/gcc/fortran/trans.cc:1950
0xa4d81d gfc_generate_function_code(gfc_namespace*)
        ../../gcc-git-unpatched/gcc/fortran/trans-decl.cc:7674
0xa1f6d1 gfc_generate_module_code(gfc_namespace*)
        ../../gcc-git-unpatched/gcc/fortran/trans.cc:2370
0x9c73f5 translate_all_program_units
        ../../gcc-git-unpatched/gcc/fortran/parse.cc:6708
0x9c73f5 gfc_parse_file()
        ../../gcc-git-unpatched/gcc/fortran/parse.cc:7027
0xa1804f gfc_be_parse_file
        ../../gcc-git-unpatched/gcc/fortran/f95-lang.cc:229
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.

Reply via email to