------- Comment #4 from fxcoudert at gcc dot gnu dot org 2007-07-04 14:36 ------- Please forget comment #3. The reason for the ICE is that substring simplification was written without taking into account the possibility of foo(14:) or foo(:14), ie one of the substring bounds being implicit. The following patch fixes it, I'm regtesting and will try to write a few more testcases before submitting it for review:
Index: expr.c =================================================================== --- expr.c (revision 126249) +++ expr.c (working copy) @@ -1503,9 +1503,19 @@ gfc_simplify_expr (gfc_expr *p, int type char *s; int start, end; - gfc_extract_int (p->ref->u.ss.start, &start); - start--; /* Convert from one-based to zero-based. */ - gfc_extract_int (p->ref->u.ss.end, &end); + if (p->ref->u.ss.start) + { + gfc_extract_int (p->ref->u.ss.start, &start); + start--; /* Convert from one-based to zero-based. */ + } + else + start = 0; + + if (p->ref->u.ss.end) + gfc_extract_int (p->ref->u.ss.end, &end); + else + end = p->value.character.length - 1; + s = gfc_getmem (end - start + 2); memcpy (s, p->value.character.string + start, end - start); s[end - start + 1] = '\0'; /* TODO: C-style string. */ -- fxcoudert at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Keywords| |patch Last reconfirmed|2007-07-04 07:47:17 |2007-07-04 14:36:19 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32594