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

--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Paul Thomas <[email protected]>:

https://gcc.gnu.org/g:b8cf80fd274cc88404a53762d243b059bfb5bf70

commit r15-11149-gb8cf80fd274cc88404a53762d243b059bfb5bf70
Author: Christopher Albert <[email protected]>
Date:   Sat Apr 11 15:13:19 2026 +0200

    fortran: Fix ICE in remap_type with deferred-length character in OMP target
[PR101760, PR102314]

    For deferred-length character types such as character(:), allocatable,
    TYPE_SIZE and TYPE_SIZE_UNIT contain SAVE_EXPRs wrapping the string
    length variable (created by variable_size in finalize_type_size).
    In gfc_omp_finish_clause, when computing OMP_CLAUSE_SIZE for implicitly
    mapped variables, the code previously used TYPE_SIZE_UNIT directly.
    Gimplifying this shared SAVE_EXPR resolves it in place, embedding a
    gimple temporary into the type's size expression.  When the enclosing
    function is later inlined, remap_type_1 walks TYPE_SIZE and encounters
    the stale temporary as an unmappable SSA name, causing an ICE in
    make_ssa_name_fn.

    Fix by computing the clause size from the array domain bounds and
    element size rather than using the type's SAVE_EXPR directly, so
    that the type's size expressions remain untouched.

            PR fortran/101760
            PR fortran/102314

    gcc/fortran/ChangeLog:

            * trans-openmp.cc (gfc_omp_finish_clause): Compute OMP_CLAUSE_SIZE
            from the array domain bounds and element size for VLA types instead
            of using TYPE_SIZE_UNIT directly, to avoid corrupting the type.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/gomp/pr101760.f90: New test.
            * gfortran.dg/gomp/pr102314.f90: New test.

    Signed-off-by: Christopher Albert <[email protected]>
    (cherry picked from commit e41fd0a99aee94734537c067f96e3502628125c6)

Reply via email to