[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896 --- Comment #8 from Mikael Morin --- (In reply to Mikael Morin from comment #7) > Well, it doesn’t fix comment #5. :-( Pilot error, it does fix it.
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896 --- Comment #7 from Mikael Morin --- (In reply to Mikael Morin from comment #6) > rough patch > Well, it doesn’t fix comment #5. :-(
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896 --- Comment #6 from Mikael Morin --- Created attachment 49609 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49609&action=edit rough patch OK, I understand better the problem. It’s not a bug that the kind argument is not used to produce code. It is known to be a constant, and that constant can be used directly at compile time. So it is the walking functions that should be fixed. I attach a rough patch doing that, it should sit on top of a full revert of pr91651.
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896
--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to Mikael Morin from comment #4)
> Elemental actual arguments are some of those arrays involved.
> Obviously one should not remove some of them in the middle of code
> generation.
> It should be done beforehand if at all.
The problem is only the KIND argument, which must be a scalar constant that
determines the function call and subsequent conversions.
The patch below solves the issue in comment#0, as well as most of
program p
implicit none
logical:: a(2)
integer:: b(2)
integer(8) :: d(2)
b = index ('xyxyz','yx', back=a)
b = index ('xyxyz','yx', back=a, kind=4) ! works now
d = index ('xyxyz','yx', back=a, kind=8) ! works now
! b = index ('xyxyz','yx', back=a, kind=8) ! ICE remains
! d = index ('xyxyz','yx', back=a, kind=4) ! ICE remains
print *, b, d
end
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 2167de455b8..dc3624f2204 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -10858,6 +10860,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr *
expr2, bool init_flag,
gfc_init_loopinfo (&loop);
/* Walk the rhs. */
+ if (expr2->value.function.isym)
+ gfc_strip_kind_from_actual (expr2->value.function.actual);
rss = gfc_walk_expr (expr2);
if (rss == gfc_ss_terminator)
/* The rhs is scalar. Add a ss for the expression. */
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index d17b623924c..b5ca67198c2 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -5149,8 +5149,8 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, gfc_expr *
expr)
/* Remove unneeded kind= argument from actual argument list when the
result conversion is dealt with in a different place. */
-static void
-strip_kind_from_actual (gfc_actual_arglist * actual)
+void
+gfc_strip_kind_from_actual (gfc_actual_arglist * actual)
{
for (gfc_actual_arglist *a = actual; a; a = a->next)
{
@@ -5297,7 +5297,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr *
expr, enum tree_code op)
{
gfc_actual_arglist *a;
a = actual;
- strip_kind_from_actual (a);
+ gfc_strip_kind_from_actual (a);
while (a)
{
if (a->name && strcmp (a->name, "dim") == 0)
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 16b4215605e..617916fa579 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -821,6 +821,7 @@ void gfc_omp_firstprivatize_type_sizes (struct
gimplify_omp_ctx *, tree);
/* In trans-intrinsic.c. */
void gfc_conv_intrinsic_mvbits (gfc_se *, gfc_actual_arglist *,
gfc_loopinfo *);
+void gfc_strip_kind_from_actual (gfc_actual_arglist *);
/* Runtime library function decls. */
extern GTY(()) tree gfor_fndecl_pause_numeric;
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896 Mikael Morin changed: What|Removed |Added CC||mikael at gcc dot gnu.org --- Comment #4 from Mikael Morin --- (In reply to anlauf from comment #3) > so something is screwing up the scalarization. Indeed. gfc_walk_expr registers all the arrays involved as an early step of scalarizing a statement. The failing assert checks that all the arrays have been used/consumed, meaning that the array registration and the actual code generation are kept synchronized. Elemental actual arguments are some of those arrays involved. Obviously one should not remove some of them in the middle of code generation. It should be done beforehand if at all.
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896
--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #2)
> Reverting the following snippet from my fix attempt for pr91651:
That snippet is necessary for the scalarizer during simplification.
The original ICE is coming from the assert in trans-expr.c:
11155 else
11156 {
11157 gcc_assert (lse.ss == gfc_ss_terminator
11158 && rse.ss == gfc_ss_terminator);
Printing lse.ss and rse.ss for
b = index ('xyxyz','yx', back=a)
b = index ('xyxyz','yx', back=a, kind=4)
one sees that the first case without kind is fine, while the second case has
(gdb) p *rse.ss
$30 = {info = 0x288c1c0, dimen = 0, dim = {0 }, loop_chain =
0x2814270,
next = 0x268eb80 , parent = 0x0, nested_ss = 0x0,
loop = 0x7fffcd90, is_alloc_lhs = 0, no_bounds_check = 0}
so something is screwing up the scalarization.
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896 Richard Biener changed: What|Removed |Added Target Milestone|--- |11.0
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896
anlauf at gcc dot gnu.org changed:
What|Removed |Added
Status|WAITING |NEW
CC||anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
Reverting the following snippet from my fix attempt for pr91651:
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index c2a4865f28f..994a9af4eb8 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -1296,11 +1296,7 @@ gfc_resolve_index_func (gfc_expr *f, gfc_actual_arglist
*a)
f->ts.type = BT_INTEGER;
if (kind)
-{
- f->ts.kind = mpz_get_si ((kind)->value.integer);
- a_back->next = NULL;
- gfc_free_actual_arglist (a_kind);
-}
+f->ts.kind = mpz_get_si ((kind)->value.integer);
else
f->ts.kind = gfc_default_integer_kind;
fixes the current PR, but breaks testcase index_4.f90
[Bug fortran/97896] [11 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:11156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896 Dominique d'Humieres changed: What|Removed |Added Last reconfirmed||2020-11-18 Status|UNCONFIRMED |WAITING Priority|P3 |P4 Ever confirmed|0 |1 --- Comment #1 from Dominique d'Humieres --- I see the ICE from GCC7 up to GCC11, including GCC 10.2.1, but not for GCC 10.2.0.
