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

            Bug ID: 127187
           Summary: [14/15/16 Regression] ICE (segfault) with ASSOCIATE
                    selector containing %LEN inquiry of deferred-length
                    character
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ivan.pribec at gmail dot com
  Target Milestone: ---

The following valid program causes an ICE (segfault) in gfc_get_symbol_decl.
Confirmed with 14.3.0 and 16.2.0; 13.3.0 compiles it and prints the
correct result, so it looks like this regression appeared in GCC 14.

$ cat ice_min.f90
program p
  character(:), allocatable :: s
  s = 'hello'
  associate (n => s%len)
    print *, n
  end associate
end program

$ gfortran-14 ice_min.f90
ice_min.f90:4:24:
    4 |   associate (n => s%len)
      |                        1
internal compiler error: Segmentation fault
0x... gfc_get_symbol_decl(gfc_symbol*)
0x... gfc_process_block_locals(gfc_namespace*)
0x... gfc_trans_block_construct(gfc_code*)
0x... gfc_generate_function_code(gfc_namespace*)

The trigger is a %LEN type-parameter inquiry of a DEFERRED-LENGTH
character (allocatable or pointer) appearing in an ASSOCIATE selector.
It also ICEs when the selector is parenthesized, i.e. (s%len), and when
the inquiry is a subexpression, e.g. s%len + 0.

Reply via email to