GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fix type-bound calls through inferred ASSOCIATE names in Fortran.

Corrects ICEs and errors in Fortran type-bound procedure calls via inferred ASSOCIATE names.

This commit resolves an internal compiler error (ICE) and related incorrect behavior in GCC’s Fortran front-end when handling type-bound procedure calls through an inferred ASSOCIATE name. Previously, such calls, especially those involving components or procedure pointers, would fail due to incorrect type lookups and missing fix-ups. The fix ensures proper reference resolution and type checking for these complex call scenarios, also addressing issues with array references following CLASS components.

In Details

This patch rectifies how GCC's Fortran front-end handles type-bound procedure calls (e.g., q%c2%get()) when the q in ASSOCIATE(a => q) has an inferred type (e.g., due to CLASS(*) or unparsed contained functions). Previously, gfc_fixup_inferred_type_refs only applied to variables, leaving procedure calls with incorrect _data references or component lookups in the wrongly guessed type, leading to ICEs in gfc_conv_component_ref. The fix introduces fixup_inferred_compcall_refs to correctly resolve these binding lookups and data references before expression resolution. Additionally…

For Context
Fortran
A high-level programming language designed for scientific and engineering applications, known for its array handling capabilities.
ASSOCIATE construct
A Fortran construct that allows a block of code to use shorter or more convenient names (aliases) for expressions or variables.
type-bound procedure
A procedure (subroutine or function) that is associated with a specific derived type in Fortran. It can be called using the % operator on an object of that type.
inferred type
A type that the compiler deduces or guesses based on context, rather than being explicitly declared by the programmer. This can happen with constructs like CLASS(*) or when dealing with forward references.
ICE
Internal Compiler Error, indicating a bug within the compiler itself.
CLASS component
A component within a Fortran derived type that can hold objects of any type, often requiring runtime type checking and dynamic dispatch.
Filed Under: fortrancompiler-internalsbugfix