GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fortran: Fix ICE for deferred-length CHARACTER results via host association

Corrects an internal compiler error when handling deferred-length CHARACTER function results through host association.

An internal compiler error (ICE) in the Fortran compiler has been fixed. The issue occurred in gfc_get_symbol_decl when asserting that a deferred-length string’s length variable resided in the same scope as its symbol. This commit corrects the scope comparison for function results within contained procedures, resolving the ICE for PR95542.

In Details

The gfc_get_symbol_decl function contains an assertion that DECL_CONTEXT (length) == sym->backend_decl for deferred-length strings. This commit corrects the assertion to DECL_CONTEXT (length) == sym->backend_decl directly when sym->backend_decl is a FUNCTION_DECL (representing an implicit function result variable), preventing an ICE when such results are accessed via host association in contained subprocedures.

For Context
ICE
Internal Compiler Error. An unexpected condition encountered by the compiler during compilation, indicating a bug in the compiler itself.
deferred-length CHARACTER
A Fortran character string whose length is not fixed at compile time but determined at runtime.
host association
A Fortran mechanism where contained procedures can access variables from their containing procedures (hosts).
FUNCTION_DECL
An internal compiler representation for a function declaration.
DECL_CONTEXT
A GCC internal representation macro that returns the scope or parent declaration of a symbol.
Filed Under: fortrancompiler bugICE