character (len=4), s1 character (len=20), pointer :: p1 s1 = 'abcd' p1 => s1(2:3)
should be rejected at compile time as len(s1(2:3)) == 2 but p1 has the length 20. This is not detected because primary.c's match_varspec contains: if (substring) primary->ts.cl = NULL; If one removes this check, the proper error: Error: Different character lengths in pointer assignment at (1) is shown. The solution is to resolve ts.cl->length for substrings if possible and only set it to NULL if it is not known at compile time. -- Summary: character pointer => target(range) should detect if lengths don't match 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=31821