Even with -std=f95 -pedantic no error is given for the following program. NAG f95 gives:
Error: st_function.f90, line 4: Subobject of constant not allowed in statement function Example (from gfortran.fortran-torture/execute/st_function.f90): subroutine with_character_dummy character (len=4) s1, s2, st4 character (len=10) st5, s0 st4 (i, j) = "0123456789"(i:j) if (st4 (1, 4) .ne. "0123" ) call abort end subroutine I could not find this restriction, when I quickly browsed the standards (F95,F2003), however, I found the following (F2003, I'm not sure whether it applies here): "C421 (R424) The length specified for a character statement function or for a statement function dummy argument of type character shall be an initialization expression." -- Summary: Wrongly allowed: Statement function with subobject of constant Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32673