From 010b9a3ec010d3cf5c76ba98e9a6438ad5bf7a76 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 13 Jun 2018 19:37:50 +0000 Subject: [PATCH] re PR fortran/86110 (ICE in gfc_resolve_character_array_constructor, at fortran/array.c:2044) 2018-06-13 Steven G. Kargl PR fortran/86110 * array.c (gfc_resolve_character_array_constructor): Avoid NULL pointer dereference. 2018-06-13 Steven G. Kargl PR fortran/86110 * gfortran.dg/pr86110.f90: New test. From-SVN: r261561 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/array.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr86110.f90 | 7 +++++++ 4 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr86110.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 25b5f37de55..05397b92dfa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-06-13 Steven G. Kargl + + PR fortran/86110 + * array.c (gfc_resolve_character_array_constructor): Avoid NULL + pointer dereference. + 2018-06-13 Cesar Philippidis PR fortran/85703 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 031ab7643a5..e4926d75147 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -2040,7 +2040,9 @@ got_charlen: gfc_ref *ref; for (ref = p->expr->ref; ref; ref = ref->next) if (ref->type == REF_SUBSTRING + && ref->u.ss.start && ref->u.ss.start->expr_type == EXPR_CONSTANT + && ref->u.ss.end && ref->u.ss.end->expr_type == EXPR_CONSTANT) break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c56ef09f726..0797df7ea5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-13 Steven G. Kargl + + PR fortran/86110 + * gfortran.dg/pr86110.f90: New test. + 2018-06-13 Cesar Philippidis PR fortran/85703 diff --git a/gcc/testsuite/gfortran.dg/pr86110.f90 b/gcc/testsuite/gfortran.dg/pr86110.f90 new file mode 100644 index 00000000000..890670f5854 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr86110.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/86110 +program p + character(:), allocatable :: x, y + x = 'abc' + y = [x(:)] ! { dg-error "Incompatible ranks 0 and 1" } +end -- 2.30.2