https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69741
--- Comment #7 from Harald Anlauf <anlauf at gmx dot de> --- (In reply to Dominique d'Humieres from comment #6) > > I think it should be clearer from the error message of _what is wrong_? > > Agreed -> Updated the summary, set to NEW and enhancement. A potential patch to generate an error message: Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 233428) +++ gcc/fortran/resolve.c (working copy) @@ -9308,6 +9310,12 @@ and stride. The FORALL index can not appear in start, end or stride. */ for (fa = code->ext.forall_iterator; fa; fa = fa->next) { + if (fa->var->ref && fa->var->ref->type == REF_ARRAY) + { + gfc_error ("FORALL index variable at %L must be scalar", + &fa->var->where); + } + /* Check if any outer FORALL index name is the same as the current one. */ for (i = 0; i < nvar; i++) Not sure if it is correct, if this is the best place, if error recovery should be improved, and if people are happy with it. With this patch, the testcase produces: pr69741.f90:5:10: forall (ii(1)=1:3 , ii(2)=1:2) 1 Error: FORALL index variable at (1) must be scalar pr69741.f90:5:21: forall (ii(1)=1:3 , ii(2)=1:2) 1 Error: FORALL index variable at (1) must be scalar pr69741.f90:5:21: forall (ii(1)=1:3 , ii(2)=1:2) 1 Error: An outer FORALL construct already has an index with this name (1) pr69741.f90:6:5: a(ii(1),ii(2)) = ii(1) * ii(2) 1 Warning: The FORALL with index 'ii' is not used on the left side of the assignment at (1) and so might cause multiple assignment to this object pr69741.f90:6:5: a(ii(1),ii(2)) = ii(1) * ii(2) 1 Warning: The FORALL with index 'ii' is not used on the left side of the assignment at (1) and so might cause multiple assignment to this object