[Bug fortran/106049] ICE in gfc_simplify_pack, at fortran/simplify.cc:6481
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 22 19:51:45 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106049
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2022-06-22
Status|UNCONFIRMED |NEW
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.
Error recovery issue while trying to simplify pack.
The chain of bad declarations passes an invalid constructor for the ARRAY
argument.
The following patch solves the problem at hand:
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index e8e3ec63669..c4ba2e615a1 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -6373,6 +6374,10 @@ gfc_simplify_pack (gfc_expr *array, gfc_expr *mask,
gfc_expr *vector)
&& !is_constant_array_expr (mask)))
return NULL;
+ if (mask->expr_type == EXPR_ARRAY
+ && gfc_is_size_zero_array (mask) != gfc_is_size_zero_array (array))
+ return NULL;
+
result = gfc_get_array_expr (array->ts.type, array->ts.kind, &array->where);
if (array->ts.type == BT_DERIVED)
result->ts.u.derived = array->ts.u.derived;
Maybe there is a better solution.
More information about the Gcc-bugs
mailing list