[Bug fortran/68566] ICE on using unusable array in reshape (double free or corruption)
anlauf at gmx dot de
gcc-bugzilla@gcc.gnu.org
Thu Mar 17 20:24:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68566
Harald Anlauf <anlauf at gmx dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gmx dot de
--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Gerhard Steinmetz from comment #4)
> Simplified a bit :
>
>
> $ cat z7.f90
> program p
> integer, parameter :: a(:) = 1
> integer, parameter :: b(2,2) = reshape([a], [2,2])
> end
This is caught by the following trivial patch:
Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c (revision 234170)
+++ gcc/fortran/simplify.c (working copy)
@@ -5163,6 +5163,9 @@
|| !is_constant_array_expr (order_exp))
return NULL;
+ if (source->shape == NULL)
+ return NULL;
+
/* Proceed with simplification, unpacking the array. */
mpz_init (index);
% gfc-trunk pr68566.f90
pr68566.f90:3:28:
integer, parameter :: a(:) = 1
1
Error: Parameter array 'a' at (1) cannot be automatic or of deferred shape
Caveat: not regtested.
Somebody please check whether the above makes sense.
More information about the Gcc-bugs
mailing list