On 3/17/26 9:44 AM, Tobias Burnus wrote:
Hi Jerry,

--- snip ---

I have the patch backported to 15 as follows. I used 'git gcc-backport' on the two patches followed by 'git rebase -i' with a squash and edit of the commit log.

I plan to commit later today

Best regards.

Jerry


commit 4fc13e39f36d07658d6609ee7aa48d636130373a (HEAD -> gcc15)
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.

    libgomp/ChangeLog:

            * testsuite/libgomp.fortran/pr120286.f90: New test.

    Signed-off-by: Christopher Albert <[email protected]>

    (cherry picked from commit 60fbabc1a182cca77d14c68a1b623c554310d135)

Reply via email to