https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110288
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- Interesting bug. Modified testcase: program test character(len=:), allocatable, dimension(:) :: array array = ["bb", "aa"] print *, findloc (array, "aa", dim=1, kind=8) contains subroutine sub (str) character(*), intent(in) :: str(:) ! print *, findloc (str, "bb", dim=1, kind=8) ! (un-)comment this line! end end program test The tree-dump shows for the findloc call: D.4354 = _gfortran_findloc2_s1 (&parm.3, &"aa"[1]{lb: 1 sz: 1}, 0, &.array, 2); Note that we pass an address where we should pass the dereferenced length. Uncommenting the marked line, we get instead (for the same source line!): D.4374 = _gfortran_findloc2_s1 (&parm.9, &"aa"[1]{lb: 1 sz: 1}, 0, .array, 2); Indeed this variant is fine and runs fine.