https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129133

--- Comment #6 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #5)
> (In reply to Harald Anlauf from comment #2)
> > Confirmed.
> > 
> > The reduced testcase in comment#1 works here for version 16.2.1 and earlier,
> > but ICEs on trunk.
> 
> On aarch64, it's much older; I still get an ICE with:
> GNU Fortran (GCC) 15.0.0 20250104 (experimental)
> 
> May it be a matter of --enable-checking?

Good point.

BTW: untested fix for the ICE:

diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 9f5e408b3e0..1349d04b038 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -5681,6 +5681,8 @@ gfc_trans_forall_1 (gfc_code * code, forall_info *
nested_forall_info)
         /* Pointer assignment inside FORALL.  */
        case EXEC_POINTER_ASSIGN:
           need_temp = gfc_check_dependency (c->expr1, c->expr2, 0);
+         /* Pointer rank remapping cannot involve a dependency.  */
+         need_temp = need_temp && (c->expr1->rank == c->expr2->rank);
          /* Avoid cases where a temporary would never be needed and where
             the temp code is guaranteed to fail.  */
          if (need_temp

Reply via email to