From 150675a88bae488e66055ad2a1eba0309ecabce3 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Tue, 31 Oct 2006 21:15:22 +0100 Subject: re PR fortran/29067 (gfc_resolve_expr(): Bad expression type) PR fortran/29067 * decl.c (gfc_set_constant_character_len): NULL-terminate the character constant string. * data.c (create_character_intializer): Likewise. * expr.c (gfc_simplify_expr): NULL-terminate the substring character constant. * primary.c (match_hollerith_constant): NULL-terminate the character constant string. * gfortran.dg/pr29067.f: New test. From-SVN: r118338 --- gcc/fortran/expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran/expr.c') diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 1f51fd0..d2da0d8 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1438,7 +1438,7 @@ gfc_simplify_expr (gfc_expr * p, int type) gfc_extract_int (p->ref->u.ss.end, &end); s = gfc_getmem (end - start + 1); memcpy (s, p->value.character.string + start, end - start); - s[end] = '\0'; /* TODO: C-style string for debugging. */ + s[end-start+1] = '\0'; /* TODO: C-style string for debugging. */ gfc_free (p->value.character.string); p->value.character.string = s; p->value.character.length = end - start; -- cgit v1.1