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

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

https://gcc.gnu.org/g:1a7be1fa3b68d8ad2fba5fc8d088a2887c1bfaa7

commit r14-12892-g1a7be1fa3b68d8ad2fba5fc8d088a2887c1bfaa7
Author: Jerry DeLisle <[email protected]>
Date:   Wed Sep 23 10:26:50 2026 -0700

    fortran: [PR127187] ICE with %LEN of deferred-length character in ASSOCIATE

    A %LEN or %KIND inquiry of a deferred-length character variable gives
    an INTEGER expression that still carried the deferred flag of the
    character typespec.  An associate-name with such a selector inherited
    it, and gfc_get_symbol_decl then segfaulted looking for its string
    length.

    A related bug: for an associate-name whose selector is deferred-length
    character, resolve_variable reset the typespec of the expression to
    that of the associate-name unless a substring reference was present.
    An inquiry reference of the associate-name, e.g. q%len, thus reverted
    to CHARACTER, giving an ICE in conv_inquiry or a spurious error on
    comparison with an INTEGER.

            PR fortran/127187

    gcc/fortran/ChangeLog:

            PR fortran/127187
            * primary.cc (gfc_match_varspec): Clear the deferred flag, and
            for KIND the charlen, of the INTEGER result of a LEN or KIND
            inquiry.
            * resolve.cc (resolve_variable): Do not reset the typespec of a
            deferred-length character associate-name expression that has an
            inquiry reference.

    gcc/testsuite/ChangeLog:

            PR fortran/127187
            * gfortran.dg/associate_90.f90: New test.

    (cherry picked from commit e0f62720743e7750eef0c86dfa23d5965e2de785)

Reply via email to