https://gcc.gnu.org/g:f99b3370224b440e0fa96e684d9fc95e447c8490

commit f99b3370224b440e0fa96e684d9fc95e447c8490
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Wed Jun 4 16:12:40 2025 +0200

    Correction régression pr68864

Diff:
---
 gcc/fortran/trans-stmt.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index afc6605c6d8f..fe968b7ab18d 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -7932,7 +7932,12 @@ gfc_trans_deallocate (gfc_code *code)
 
          if (al->expr->ts.type == BT_CLASS)
            {
-             gfc_reset_vptr (&se.pre, al->expr);
+             if (is_subref_array (al->expr))
+               /* Finalisation code can create bogus
+                  array subreferences, ignore those.  */
+               ;
+             else
+               gfc_reset_vptr (&se.pre, al->expr);
              if (UNLIMITED_POLY (al->expr)
                  || (al->expr->ts.type == BT_DERIVED
                      && al->expr->ts.u.derived->attr.unlimited_polymorphic))

Reply via email to