re PR fortran/50409 (SIGSEGV in gfc_simplify_expr)

PR fortran/50409
	* expr.c (gfc_simplify_expr): Substrings can't have negative
	length.
	* gcc/testsuite/gfortran.dg/string_5.f90: Improve testcase.

From-SVN: r181181
This commit is contained in:
Francois-Xavier Coudert 2011-11-08 23:15:11 +00:00 committed by François-Xavier Coudert
parent 6ef982714c
commit b8bc0ff76b
4 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/50409
* expr.c (gfc_simplify_expr): Substrings can't have negative
length.
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/50334

View File

@ -1853,8 +1853,8 @@ gfc_simplify_expr (gfc_expr *p, int type)
if (p->ref && p->ref->u.ss.end)
gfc_extract_int (p->ref->u.ss.end, &end);
if (end < 0)
end = 0;
if (end < start)
end = start;
s = gfc_get_wide_string (end - start + 2);
memcpy (s, p->value.character.string + start,

View File

@ -1,3 +1,8 @@
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/50409
* gcc/testsuite/gfortran.dg/string_5.f90: Improve testcase.
2011-10-23 Jason Merrill <jason@redhat.com>
PR c++/50835

View File

@ -1,7 +1,14 @@
! { dg-do compile }
! PR fortran/48876 - this used to segfault.
! Test case contributed by mhp77 (a) gmx.at.
program test
! PR fortran/48876 - this used to segfault.
! Test case contributed by mhp77 (a) gmx.at.
character :: string = "string"( : -1 )
! PR fortran/50409
character v(3)
v = (/ ('123'(i:1), i = 3, 1, -1) /)
print *, v
end program test