https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96255
--- Comment #9 from anlauf at gcc dot gnu.org --- (In reply to kargl from comment #8) > New patch. This adds a bool component to gfc_forall_iterator so > that an iterator with an index-name that shadows a variable from > outer scope can be marked. Shadowing only occurs when a type-spec > causes the kind type parameter to differ from the kind type > parameter of the outer scope variable. F2018: 19.4 Statement and construct entities (6) The name of a variable that appears as an index-name in a DO CONCURRENT construct, FORALL statement, or FORALL construct has a scope of the statement or construct. ... So the index variable may inherit the kind of a declared variable if there is no typespec, but we always have to shadow a variable of that name from the outer scope. This is confirmed by Intel and NAG.