https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128735
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:de431c751cef6ef0d7e9e54f67ef64afc6d05b09 commit r17-6642-gde431c751cef6ef0d7e9e54f67ef64afc6d05b09 Author: Jerry DeLisle <[email protected]> Date: Sat Nov 14 17:52:05 2026 -0800 fortran: [PR128735] END ASSOCIATE restores old CLASS array selector When the selector of ASSOCIATE or SELECT TYPE was a polymorphic array pointer or allocatable, the end of the block copied the descriptor the selector had on entry back into it. This undid a pointer assignment to the selector inside the block, and after a DEALLOCATE of the selector it restored the freed array, giving a double free. The copy-back is needed only for SELECT RANK, whose associate name can be allocated or pointer-assigned; other associate names are neither POINTER nor ALLOCATABLE. Keep it only for an assumed-rank selector. Assisted-by: Claude Opus 5.5 PR fortran/128735 gcc/fortran/ChangeLog: * trans-stmt.cc (trans_associate_var): Copy the class container of a class array associate name back to the selector only for SELECT RANK. gcc/testsuite/ChangeLog: * gfortran.dg/pr128735.f90: New test.
