[Bug fortran/28081] Undue compile-time error for zero-sized substring
fxcoudert at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Jun 19 11:52:00 GMT 2006
------- Comment #1 from fxcoudert at gcc dot gnu dot org 2006-06-19 11:39 -------
Here is a patch that fixes this problem (and gives a slightly better, IMHO,
error message):
Index: resolve.c
===================================================================
--- resolve.c (revision 114721)
+++ resolve.c (working copy)
@@ -2542,7 +2542,9 @@
return FAILURE;
}
- if (compare_bound_int (ref->u.ss.start, 1) == CMP_LT)
+ if (compare_bound_int (ref->u.ss.start, 1) == CMP_LT
+ && (compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_EQ
+ || compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_GT))
{
gfc_error ("Substring start index at %L is less than one",
&ref->u.ss.start->where);
@@ -2570,9 +2572,11 @@
}
if (ref->u.ss.length != NULL
- && compare_bound (ref->u.ss.end, ref->u.ss.length->length) == CMP_GT)
+ && compare_bound (ref->u.ss.end, ref->u.ss.length->length) == CMP_GT
+ && (compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_EQ
+ || compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_GT))
{
- gfc_error ("Substring end index at %L is out of bounds",
+ gfc_error ("Substring end index at %L exceeds the string length",
&ref->u.ss.start->where);
return FAILURE;
}
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Keywords| |patch
Known to fail| |4.2.0 4.1.2
Last reconfirmed|0000-00-00 00:00:00 |2006-06-19 11:39:33
date| |
Target Milestone|--- |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28081
More information about the Gcc-bugs
mailing list