https://gcc.gnu.org/g:3e3893107aacc8a9386397c7c53fd1501484b2d8

commit 3e3893107aacc8a9386397c7c53fd1501484b2d8
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 a26491839b39..e203be6ffb9f 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -7998,7 +7998,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