https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85603
Bug ID: 85603 Summary: ICE with character array substring assignment Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: w6ws at earthlink dot net Target Milestone: --- The following test case causes an ICE. First noticed with v5.4, but also happens with v4.8 and a 4/26/2018 snapshot of v9.0.0. Intel and NAG compile and run this. PGI v17.10 also gets an ICE...: program strlen_bug implicit none character(:), allocatable :: strings(:) integer :: maxlen strings = [ character(32) :: & 'short', & 'somewhat longer' ] maxlen = maxval (len_trim (strings)) print *, 'max length =', maxlen ! causes ICE ! strings = strings(:)(:maxlen) print *, strings end program wws@w6ws-4:/rootsda5/home/wws/fortran/array_cons$ /usr/local/gcc-trunk/bin/gfortran --version GNU Fortran (GCC) 9.0.0 20180426 (experimental) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. wws@w6ws-4:/rootsda5/home/wws/fortran/array_cons$ /usr/local/gcc-trunk/bin/gfortran strlen_bug.f90 strlen_bug.f90:13:0: strings = strings(:)(:maxlen) internal compiler error: Segmentation fault 0xce260f crash_signal ../../gcc-trunk/gcc/toplev.c:325 0x7722a7 gfc_alloc_allocatable_for_assignment(gfc_loopinfo*, gfc_expr*, gfc_expr*) ../../gcc-trunk/gcc/fortran/trans-array.c:9915 0x7a3c24 gfc_trans_assignment_1 ../../gcc-trunk/gcc/fortran/trans-expr.c:10329 0x754537 trans_code ../../gcc-trunk/gcc/fortran/trans.c:1828 0x7e7b2f gfc_trans_block_construct(gfc_code*) ../../gcc-trunk/gcc/fortran/trans-stmt.c:2058 0x754327 trans_code ../../gcc-trunk/gcc/fortran/trans.c:1924 0x788f45 gfc_generate_function_code(gfc_namespace*) ../../gcc-trunk/gcc/fortran/trans-decl.c:6507 0x7081d0 translate_all_program_units ../../gcc-trunk/gcc/fortran/parse.c:6121 0x7081d0 gfc_parse_file() ../../gcc-trunk/gcc/fortran/parse.c:6324 0x75107f gfc_be_parse_file ../../gcc-trunk/gcc/fortran/f95-lang.c:204 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. wws@w6ws-4:/rootsda5/home/wws/fortran/array_cons$