re PR fortran/68566 (ICE on using unusable array in reshape (double free or corruption))

2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68566
	* check.c (gfc_check_reshape): Check for constant expression.

2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68566
	* gfortran.dg/pr68566.f90: new test.

From-SVN: r238911
This commit is contained in:
Steven G. Kargl 2016-07-30 23:01:06 +00:00
parent 8bada5cd4e
commit 9fcb28197f
4 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68566
* check.c (gfc_check_reshape): Check for constant expression.
2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/69867

View File

@ -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;

View File

@ -1,3 +1,8 @@
2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68566
* gfortran.dg/pr68566.f90: new test.
2016-07-30 Martin Sebor <msebor@redhat.com>
PR c++/60760

View File

@ -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