Commit 9fcb2819 by Steven G. Kargl

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
parent 8bada5cd
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
* decl.c (build_struct): Ensure that pointers point to something.
......
......@@ -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;
......
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
......
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment