https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56007
--- Comment #4 from Harald Anlauf <anlauf at gmx dot de> --- (In reply to Tobias Schlüter from comment #3) > Just for the fun of it, another confusing way this error message appears: > $ cat t3.f90 > character c(5) > > do c=2,3 > end do > > END > $ gfortran t3.f90 > t3.f90:3.4: > > do c=2,3 > 1 > Error: Loop variable at (1) cannot be a sub-component > t3.f90:4.3: > > end do > 1 > Error: Expecting END PROGRAM statement at (1) > $ > > Of course this behavior is expected once you look at the code. The above error message is somewhat improved with the following patch: Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 232904) +++ gcc/fortran/match.c (working copy) @@ -877,6 +877,12 @@ if (m != MATCH_YES) return MATCH_NO; + if (var->ts.type == BT_CHARACTER) + { + gfc_error ("Loop variable at %C cannot be of type CHARACTER"); + goto cleanup; + } + /* F2008, C617 & C565. */ if (var->symtree->n.sym->attr.codimension) { I now get: t3.f90:3:4: do c=2,3 1 Error: Loop variable at (1) cannot be of type CHARACTER t3.f90:4:3: end do 1 Error: Expecting END PROGRAM statement at (1)