GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
fortran

Fortran: [PR126170] Fix LTO ICE in copy_function_or_variable

Fixes a Link-Time Optimization (LTO) Internal Compiler Error (ICE) in gfortran related to module symbol handling.

This commit resolves a Link-Time Optimization (LTO) Internal Compiler Error (ICE) in the gfortran compiler, addressing PR126170. The error occurred when a contained procedure within a Fortran module redundantly used another module that was already visible through host association. This led to the module reader creating duplicate derived type definitions. The fix ensures that modules are not re-imported if their symbols are already accessible via host association.

In Details

In gfortran, a Link-Time Optimization (LTO) Internal Compiler Error (ICE) related to copy_function_or_variable has been fixed (PR fortran/126170). The issue stemmed from a redundant USE statement of a module within a contained procedure, which was already accessible via host association. This caused gfc_find_derived_vtab and gfc_is_finalizable to encounter stale, non-use-associated duplicate vtab symbols. The fix in gcc/fortran/module.cc prevents re-importing symbols that are already visible through host association from the same module, thereby resolving the ICE.

For Context
Link-Time Optimization (LTO)
An optimization technique where the compiler performs optimizations across multiple object files during the linking stage, rather than just within individual compilation units. This allows for more global code analysis and optimization.
Internal Compiler Error (ICE)
An unexpected condition or bug within the compiler itself that causes it to terminate abnormally. These are distinct from runtime errors in the compiled program.
gfortran
The GNU Fortran compiler, part of the GCC suite.
host association
In Fortran, a mechanism where entities in an outer scope (host unit) are accessible within an inner scope (contained procedure or child unit) without an explicit USE statement.
derived type
A user-defined composite data type in Fortran, similar to a struct or class in other languages.
PR126170
A Problem Report (PR) identifier in the GCC bug tracking system, indicating a specific issue that has been reported and is being addressed.
Filed Under: fortranLTOcompiler errorbugfix