aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2011-11-08 23:15:11 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2011-11-08 23:15:11 +0000
commitb8bc0ff76b12959e1aefafda407c03604605728c (patch)
tree446e102781c3c6ba28c0236407a02027e2d0996b /gcc
parent6ef982714cf2a0a796cd55805ceeeaa07726a903 (diff)
downloadgcc-b8bc0ff76b12959e1aefafda407c03604605728c.zip
gcc-b8bc0ff76b12959e1aefafda407c03604605728c.tar.gz
gcc-b8bc0ff76b12959e1aefafda407c03604605728c.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/expr.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/string_5.f9011
4 files changed, 22 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4ae0e5b..29294f7 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
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
* invoke.texi (-finit-*): Document interaction with
-Wuninitialized.
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 504c7cf..f241455 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -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,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b0cbbb6..de8cdc4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/string_5.f90 b/gcc/testsuite/gfortran.dg/string_5.f90
index 87ec709..ef29156 100644
--- a/gcc/testsuite/gfortran.dg/string_5.f90
+++ b/gcc/testsuite/gfortran.dg/string_5.f90
@@ -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