diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-07-30 18:17:55 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-07-30 18:17:55 +0000 |
commit | 7d0300ed911d8dfec7943c88af83ed4e4563a5d1 (patch) | |
tree | 18675d430cf2966640ff55d153fa65f82065dd15 /gcc | |
parent | b3421a06f981f875e0aee932b4f80c52dcb37e72 (diff) | |
download | gcc-7d0300ed911d8dfec7943c88af83ed4e4563a5d1.zip gcc-7d0300ed911d8dfec7943c88af83ed4e4563a5d1.tar.gz gcc-7d0300ed911d8dfec7943c88af83ed4e4563a5d1.tar.bz2 |
re PR fortran/48876 (ICE when initializing character variable with zero-length string)
2011-07-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48876
* expr.c (gfc_simplify_expr): If end of a string is less
than zero, set it to zero.
2011-07-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48876
* gfortran.dg/string_5.f90: New test.
From-SVN: r176961
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/string_5.f90 | 7 |
4 files changed, 21 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 89825e3..6be5141 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-07-30 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/48876 + * expr.c (gfc_simplify_expr): If end of a string is less + than zero, set it to zero. + 2011-07-28 Jakub Jelinek <jakub@redhat.com> PR fortran/31067 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index e5394b8..549feee 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1839,6 +1839,9 @@ 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; + s = gfc_get_wide_string (end - start + 2); memcpy (s, p->value.character.string + start, (end - start) * sizeof (gfc_char_t)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 187a808..3a681d8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-07-30 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/48876 + * gfortran.dg/string_5.f90: New test. + 2011-07-29 Jason Merrill <jason@redhat.com> PR c++/49867 diff --git a/gcc/testsuite/gfortran.dg/string_5.f90 b/gcc/testsuite/gfortran.dg/string_5.f90 new file mode 100644 index 0000000..87ec709 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/string_5.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/48876 - this used to segfault. +! Test case contributed by mhp77 (a) gmx.at. +program test + character :: string = "string"( : -1 ) +end program test + |