https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129176

--- Comment #1 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:7a8ce085d132cb149f61f2500827bb0fc740ea60

commit r17-6856-g7a8ce085d132cb149f61f2500827bb0fc740ea60
Author: Jerry DeLisle <[email protected]>
Date:   Mon Nov 30 10:08:07 2026 -0800

    fortran: [PR129176] POINTER and ALLOCATABLE DO variables in OpenMP loops

    The private copy of a POINTER DO variable has an undefined association
    status (OpenMP 4.0, 2.14.3.3), so an OpenMP loop that privatizes it, or
    a sequential DO inside a parallel construct, defines it through an
    unassociated pointer and crashes, with no diagnostic.  Warn with
    -Wopenmp, except for TILE, UNROLL and loops under a generated loop,
    which do not privatize the variable.  An ALLOCATABLE DO variable is
    valid, but the PR128791 change excluded it, so in a collapsed SIMD nest
    it stayed shared or firstprivate and its final value was lost; make it
    lastprivate like other DO variables there.

    Assisted-by: Claude Opus 5.5

            PR fortran/129176

    gcc/fortran/ChangeLog:

            * openmp.cc (gfc_resolve_do_iterator): Warn for a POINTER DO
            variable privatized in an OpenMP construct.
            (resolve_omp_do): Warn for a POINTER loop iteration variable,
            except for TILE, UNROLL and generated loops.
            * trans-openmp.cc (gfc_trans_omp_do): Make an ALLOCATABLE DO
            variable of a collapsed SIMD loop lastprivate.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/gomp/loop-iter-var-pointer-1.f90: New test.

    libgomp/ChangeLog:

            * testsuite/libgomp.fortran/non-rectangular-loop-3.f90: Expect the
            POINTER iteration variable warning.
            * testsuite/libgomp.fortran/non-rectangular-loop-4.f90: Likewise.
            * testsuite/libgomp.fortran/simd-collapse-step-2.f90: New test.

Reply via email to