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

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

https://gcc.gnu.org/g:37724f8a90f0b9ebc5d8883ea0af71edaef2cc35

commit r16-9106-g37724f8a90f0b9ebc5d8883ea0af71edaef2cc35
Author: Jerry DeLisle <[email protected]>
Date:   Wed May 27 21:00:19 2026 -0700

    fortran: ICE in DO CONCURRENT with DEFAULT(NONE) inside ASSOCIATE

    Two bugs in check_default_none_expr caused a segfault when a DO CONCURRENT
    with inline type-spec iterators (e.g. "integer :: i = 1:10") contained an
    ASSOCIATE construct.

    Bug 1: sym->ns->code was used to locate the ext.concur.forall_iterator
    list.  When a symbol's namespace is an ASSOCIATE body, sym->ns->code is an
    EXEC_BLOCK node, not the DO CONCURRENT node; reading ext.concur from it
    interprets the wrong union member and yields a garbage pointer.  Fix: use
    d->code instead, the DO CONCURRENT gfc_code node passed through the
walker's
    data parameter, which is always the correct node.

    Bug 2: inline type-spec iterators are shadow iterators, stored internally
    with a leading underscore prepended to the name.  The comparison of the
    iterator's symtree name against the user-visible sym->name must skip that
    underscore by advancing iter_name one character when iter->shadow is set.

    Assisted by: Claude Sonnet 4.6

            PR fortran/125529

    gcc/fortran/ChangeLog:

            * resolve.cc (check_default_none_expr): Use d->code instead of
            sym->ns->code to locate the DO CONCURRENT forall_iterator list,
            avoiding a wrong-union-member read when the symbol's namespace is
            an ASSOCIATE body.  Skip leading underscore when comparing iterator
            names for shadow iterators.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/do_concurrent_assoc_default_none.f90: New test.

    (cherry picked from commit 7fd7fdfa4c228089277ddfbadda55dc8c3077726)

Reply via email to