https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130
Bug ID: 85130 Summary: Substrings out of range are not rejected Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- F2003, 6.1.1: Let the characters in the parent string be numbered 1, 2, 3, ..., n, where n is the length of the parent string. Then the characters in the substring are those from the parent string from the starting point and proceeding in sequence up to and including the ending point. Both the starting point and the ending point shall be within the range 1, 2, ..., n unless the starting point exceeds the ending point, in which case the substring has length zero. If the starting point is not specified, the default value is 1. If the ending point is not specified, the default value is n. We correctly reject this for simple cases, but not for all. For example, substr_6.f90 has ! { dg-do run } ! { dg-options "-std=legacy" } ! ! Check that NULs don't mess up constant substring simplification CHARACTER(5), parameter :: c0(1) = (/ "123" // ACHAR(0) // "5" /) CHARACTER*5 c(1) CHARACTER(1), parameter :: c1(5) = (/ "1", "2", "3", ACHAR(0), "5" /) c = c0(1)(-5:-8) if (c(1) /= " ") STOP 1