https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102885
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> --- Further reduced testcase: module m use iso_c_binding, only: c_char, c_size_t implicit none (type, external) contains subroutine ar3 (xn, n) bind(C) integer(c_size_t), intent(in) :: n character(len=n) :: xn(..) select rank(xn) rank(1) xn(1:1) = ['FDGhf'] end select end end Works if I add "VALUE :: n", i.e. 'n' is passed by value instead of by reference.