re PR fortran/83864 (ICE in gfc_apply_init, at fortran/expr.c:4271)
authorHarald Anlauf <anlauf@gmx.de>
Thu, 18 Jan 2018 07:54:17 +0000 (07:54 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 18 Jan 2018 07:54:17 +0000 (07:54 +0000)
2018-01-17  Harald Anlauf  <anlauf@gmx.de>

PR fortran/83864
* expr.c (add_init_expr_to_sym): Do not dereference NULL pointer.

2018-01-17  Harald Anlauf  <anlauf@gmx.de>

PR fortran/83864
* gfortran.dg/pr83864.f90: New test.

From-SVN: r256837

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr83864.f90 [new file with mode: 0644]

index 30525332f66009f46e7b11562d183ea3c5919274..3fd3bf8234ce81d32a770983b43d67b8dd6f8018 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-17  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/83864
+       * expr.c (add_init_expr_to_sym): Do not dereference NULL pointer.
+
 2018-01-17  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/83874
index 45ccc184fc18a27d09fabebe8d978b2a2242fbb6..936b6b638b79cbb14712eb517d8ae96a7ada9aea 100644 (file)
@@ -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))
         {
index 492c650911ebdd10f08610410152c66a87ad1acf..e166d03b170e3919c65ead3ceb4385b9baf6213d 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-17  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/83864
+       * gfortran.dg/pr83864.f90: New test.
+
 2018-01-17  Jeff Law  <law@redhat.com>
 
        PR testsuite/83883
diff --git a/gcc/testsuite/gfortran.dg/pr83864.f90 b/gcc/testsuite/gfortran.dg/pr83864.f90
new file mode 100644 (file)
index 0000000..3bf568a
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do run }
+! PR fortran/83864
+!
+! Derived from PR by Contributed by Gerhard Steinmetz <gscfq@t-online.de>
+!
+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