From fcf7923742d34c0cb7270594d4cdab4ea1199672 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 18 Jan 2018 07:54:17 +0000 Subject: [PATCH] re PR fortran/83864 (ICE in gfc_apply_init, at fortran/expr.c:4271) 2018-01-17 Harald Anlauf PR fortran/83864 * expr.c (add_init_expr_to_sym): Do not dereference NULL pointer. 2018-01-17 Harald Anlauf PR fortran/83864 * gfortran.dg/pr83864.f90: New test. From-SVN: r256837 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/expr.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr83864.f90 | 13 +++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr83864.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 30525332f66..3fd3bf8234c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2018-01-17 Harald Anlauf + + PR fortran/83864 + * expr.c (add_init_expr_to_sym): Do not dereference NULL pointer. + 2018-01-17 Harald Anlauf PR fortran/83874 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 45ccc184fc1..936b6b638b7 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4267,7 +4267,7 @@ gfc_apply_init (gfc_typespec *ts, symbol_attribute *attr, gfc_expr *init) gfc_set_constant_character_len (len, init, -1); else if (init && init->ts.type == BT_CHARACTER - && init->ts.u.cl + && init->ts.u.cl && init->ts.u.cl->length && mpz_cmp (ts->u.cl->length->value.integer, init->ts.u.cl->length->value.integer)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 492c650911e..e166d03b170 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-17 Harald Anlauf + + PR fortran/83864 + * gfortran.dg/pr83864.f90: New test. + 2018-01-17 Jeff Law PR testsuite/83883 diff --git a/gcc/testsuite/gfortran.dg/pr83864.f90 b/gcc/testsuite/gfortran.dg/pr83864.f90 new file mode 100644 index 00000000000..3bf568ab316 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr83864.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +! PR fortran/83864 +! +! Derived from PR by Contributed by Gerhard Steinmetz +! +program p + implicit none + type t + character :: c(3) = transfer('abc','z',3) + end type t + type(t) :: x + if (any (x%c /= ["a", "b", "c"])) call abort () +end -- 2.30.2