https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120286
--- Comment #5 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:60fbabc1a182cca77d14c68a1b623c554310d135 commit r16-8123-g60fbabc1a182cca77d14c68a1b623c554310d135 Author: Christopher Albert <[email protected]> Date: Tue Mar 10 20:59:48 2026 +0100 fortran: Preserve scalar class pointers in OpenMP privatization [PR120286] OpenMP privatization currently treats scalar class pointers like owned polymorphic class objects. In the worker cleanup for private/firstprivate class pointers, the generated code finalizes and frees ptr._data even though the clause only copied pointer association status from a shared target. Fix this in gfc_omp_clause_copy_ctor and gfc_omp_clause_dtor by unwrapping saved descriptors first and by recognizing class-pointer container types locally in those hooks. That keeps scalar class pointers on the association-only path without changing the broader polymorphic mapping classification used for OpenMP warnings and deep mapping. Add a runtime regression test for the original private(ptr) crash plus a firstprivate(ptr) association check. gcc/fortran/ChangeLog: PR fortran/120286 * trans-openmp.cc (gfc_is_class_pointer_type): New helper. (gfc_omp_clause_copy_ctor): Unwrap saved descriptors before deciding whether privatization should preserve only pointer association. Handle scalar class pointers on that path too. (gfc_omp_clause_dtor): Likewise. gcc/testsuite/ChangeLog: PR fortran/120286 * gfortran.dg/pr120286.f90: New test. Signed-off-by: Christopher Albert <[email protected]>
