https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127187
--- Comment #1 from Ivan Pribec <ivan.pribec at gmail dot com> ---
Here's a slightly extended test case that passes in gfortran 13.3, but ICE's in
16.2. It also passes in ifort, ifx and flang.
program assoc_len_kind
implicit none
character(:), allocatable :: s
character(7) :: f = 'seven07'
complex :: z = (1., 2.)
s = 'hello'
! deferred-length %len (ICE in 16.2)
associate (n => s%len)
if (n /= 5) error stop 1
end associate
! parenthesized inquiry
associate (n => (s%len))
if (n /= 5) error stop 2
end associate
! fixed-length %len
associate (n => f%len)
if (n /= 7) error stop 3
end associate
! inquiry inside a larger expression
associate (n => s%len + 0)
if (n /= 5) error stop 4
end associate
! %kind alone, and mixed list
associate (k => z%kind)
if (k /= kind(z)) error stop 5
end associate
associate (k => z%kind, n => s%len)
if (k /= kind(z)) error stop 6
if (n /= 5) error stop 7
end associate
! value must be captured at ASSOCIATE execution, not re-evaluated
associate (n => s%len)
s = 'longer_string'
if (n /= 5) error stop 8
end associate
end program