From: Steven G. Kargl Date: Sat, 30 Jul 2016 23:01:06 +0000 (+0000) Subject: re PR fortran/68566 (ICE on using unusable array in reshape (double free or corruption)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9fcb28197f056fd7e1ace31db7aa7f0104f7eb96;p=gcc.git re PR fortran/68566 (ICE on using unusable array in reshape (double free or corruption)) 2016-07-30 Steven G. Kargl PR fortran/68566 * check.c (gfc_check_reshape): Check for constant expression. 2016-07-30 Steven G. Kargl PR fortran/68566 * gfortran.dg/pr68566.f90: new test. From-SVN: r238911 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 13f1a9089db..32a1e86ab25 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-07-30 Steven G. Kargl + + PR fortran/68566 + * check.c (gfc_check_reshape): Check for constant expression. + 2016-07-30 Steven G. Kargl PR fortran/69867 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 085ac40c870..288957aaa34 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -3827,7 +3827,7 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape, if (!type_check (order, 3, BT_INTEGER)) return false; - if (order->expr_type == EXPR_ARRAY) + if (order->expr_type == EXPR_ARRAY && gfc_is_constant_expr (order)) { int i, order_size, dim, perm[GFC_MAX_DIMENSIONS]; gfc_expr *e; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a73a39defc6..e4ce4c7eceb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-30 Steven G. Kargl + + PR fortran/68566 + * gfortran.dg/pr68566.f90: new test. + 2016-07-30 Martin Sebor PR c++/60760 diff --git a/gcc/testsuite/gfortran.dg/pr68566.f90 b/gcc/testsuite/gfortran.dg/pr68566.f90 new file mode 100644 index 00000000000..160e9ac58f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr68566.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +program p + character(len=20) s1, s2 + integer, allocatable :: n(:) + n = [2,1] + s1 = '1 5 2 6 3 0 4 0' + write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], [2,1]) + if (trim(s1) /= trim(s2)) call abort + write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], n) + if (trim(s1) /= trim(s2)) call abort + write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], [n]) + if (trim(s1) /= trim(s2)) call abort +end