This bug seems to be a regression from past versions, gfortran 10-13 worked without error. Bug #100860 describes a similar issue, but gfortran 14.1.0 generates an ICE while the original issue had a seg fault. I believe the error is coming from the usage of indices to get a substring from a class(*) type. I've simplified the test program from the original report to be more compact: program test implicit none character (len=:), allocatable :: str str = "examplestring" call foo(str,13) contains subroutine foo(bar, strlen) class(*), intent (in) :: bar integer, intent (in) :: strlen select type (bar) type is (character(*)) print *, 'String is "', bar(1:strlen), '"' ! fails here class default print *, "Not the right type" end select end subroutine end program test
Error output: test2.F90:18:43: 18 | print *, 'String is "', bar(1:strlen), '"' ! fails here | 1 internal compiler error: Segmentation fault 0xe5329f crash_signal ../.././gcc/toplev.cc:319 0x8ced67 gfc_conv_scalarized_array_ref ../.././gcc/fortran/trans-array.cc:3938 0x8cfc46 gfc_conv_array_ref(gfc_se*, gfc_array_ref*, gfc_expr*, locus*) ../.././gcc/fortran/trans-array.cc:4094 0x90a946 gfc_conv_variable ../.././gcc/fortran/trans-expr.cc:3189 0x90d6c2 gfc_conv_expr_reference(gfc_se*, gfc_expr*) ../.././gcc/fortran/trans-expr.cc:9943 0x9336f2 gfc_trans_transfer(gfc_code*) ../.././gcc/fortran/trans-io.cc:2609 0x8c48c7 trans_code ../.././gcc/fortran/trans.cc:2583 0x9312d9 build_dt ../.././gcc/fortran/trans-io.cc:2053 0x8c4827 trans_code ../.././gcc/fortran/trans.cc:2555 0x950234 gfc_trans_block_construct(gfc_code*) ../.././gcc/fortran/trans-stmt.cc:2377 0x8c4aa7 trans_code ../.././gcc/fortran/trans.cc:2459 0x9472dc gfc_trans_select_type_cases ../.././gcc/fortran/trans-stmt.cc:3020 0x9519a9 gfc_trans_select_type(gfc_code*) ../.././gcc/fortran/trans-stmt.cc:3729 0x8c4a07 trans_code ../.././gcc/fortran/trans.cc:2479 0x950234 gfc_trans_block_construct(gfc_code*) ../.././gcc/fortran/trans-stmt.cc:2377 0x8c4aa7 trans_code ../.././gcc/fortran/trans.cc:2459 0x8f4b24 gfc_generate_function_code(gfc_namespace*) ../.././gcc/fortran/trans-decl.cc:7880 0x8f4914 gfc_generate_contained_functions ../.././gcc/fortran/trans-decl.cc:5995 0x8f4914 gfc_generate_function_code(gfc_namespace*) ../.././gcc/fortran/trans-decl.cc:7812 0x866986 translate_all_program_units ../.././gcc/fortran/parse.cc:7099 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.
This bug has already been reported as pr114874 and just been fixed last week. *** This bug has been marked as a duplicate of bug 114874 ***