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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually tested (though so far just on this testcase and nothing else) patch:
2026-07-17  Jakub Jelinek  <[email protected]>

        PR fortran/126303
        * frontend-passes.cc (inner_loop_may_be_skipped): If inner loop
iterator
        is not integral, return true.

        * gfortran.dg/pr126303.f: New test.

--- gcc/fortran/frontend-passes.cc.jj   2026-06-01 23:00:32.170970754 +0200
+++ gcc/fortran/frontend-passes.cc      2026-07-17 16:27:33.510790350 +0200
@@ -2778,6 +2778,9 @@ inner_loop_may_be_skipped (int loop_inde
       if (loop == NULL || loop->ext.iterator == NULL ||
loop->ext.iterator->var == NULL)
        return true;

+      if (loop->ext.iterator->var->symtree->n.sym->ts.type != BT_INTEGER)
+       return true;
+
       if (!evaluate_loop_bound (loop->ext.iterator->step, outer_sym,
outer_val, do_step))
        return true;

--- gcc/testsuite/gfortran.dg/pr126303.f.jj     2026-07-17 16:24:51.390803180
+0200
+++ gcc/testsuite/gfortran.dg/pr126303.f        2026-07-17 16:24:33.510025181
+0200
@@ -0,0 +1,9 @@
+! PR fortran/126303
+! { dg-do compile }
+! { dg-options "-std=legacy" }
+      COMMON FOO(8)
+      DO 10 M=1,8
+        DO 10 T=0D0,1D0
+          FOO(M)=1
+   10 CONTINUE
+      END

Reply via email to