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

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

https://gcc.gnu.org/g:539875dc1fa11a189da11105d004baf8aa218e7e

commit r14-12579-g539875dc1fa11a189da11105d004baf8aa218e7e
Author: Paul Thomas <[email protected]>
Date:   Tue May 12 18:21:38 2026 +0100

    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]>

Reply via email to