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

--- Comment #3 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:e8d83da8777f43d5ad58ef17aebfcea095214dbd

commit r17-5549-ge8d83da8777f43d5ad58ef17aebfcea095214dbd
Author: Jerry DeLisle <[email protected]>
Date:   Tue Aug 11 13:05:22 2026 -0700

    fortran: [PR126798] ICE for ASSOCIATE selector returning a procedure
pointer

    F2023:C1105 requires an ASSOCIATE selector to be neither a designator of
    a procedure pointer nor a function reference returning one.  The check in
    resolve_assoc_var was gated on EXPR_VARIABLE, so a function reference
    never reached it: the associate name took the type of the function's
    result interface and the pointer value was then converted into it,
    gimplifying to

      c = (real(kind=4)) _1;

    This is not new in 17.  Every release from 13 on produces the same
    invalid GIMPLE; it surfaces as an ICE only where verify_gimple runs, so
    release-branch builds (--enable-checking=release) compile it silently
    and -fchecking reproduces the diagnostic there.

    Hoist the check and add an EXPR_FUNCTION arm keyed on the function result
    symbol.  Calling a procedure pointer stays valid: there the resolved
    symbol is the pointer itself and its result symbol is itself, so the
    result is taken from the interface instead.

    gcc/fortran/ChangeLog:

            PR fortran/126798
            * resolve.cc (resolve_assoc_var): Move the procedure pointer check
            out of the EXPR_VARIABLE branch and diagnose a function reference
            whose result is a procedure pointer.

    gcc/testsuite/ChangeLog:

            PR fortran/126798
            * gfortran.dg/associate_85.f90: New test.
  • [Bug fortran/126798] ICE on inv... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to