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

Fix ICE with recursively defined derived type

Resolves an ICE in Fortran when handling allocatable arrays in recursively defined derived types.

This commit fixes an Internal Compiler Error (ICE) in the Fortran frontend when dealing with recursively defined derived types that contain allocatable arrays. The fix extends a mechanism for handling allocatable arrays of the same type to scalars within these structures. It ensures that descriptors are created for these scalars and passed to the deep copy library, resolving the ICE and enabling compilation of such code. New test cases are added to cover this scenario.

In Details

The Fortran frontend's type translation logic, specifically in trans-array.cc, encountered an ICE when processing recursively defined derived types containing allocatable components. This change modifies structure_alloc_comps to ensure that scalars that are part of such recursive structures, and are also allocatable, are handled similarly to allocatable arrays. This involves creating appropriate descriptors and utilizing the deep copy library, thus fixing a limitation in how these complex type structures were managed.

For Context
derived type
In Fortran, a user-defined data type that can aggregate variables of different types and kinds.
allocatable
A Fortran attribute that allows a variable (array or scalar) to be dynamically allocated and deallocated during program execution.
ICE
Internal Compiler Error, a condition where the compiler encounters an unrecoverable error during the compilation process and must abort.
descriptor
A data structure containing metadata about a variable, such as its type, shape, and memory address, particularly relevant for dynamically allocated or complex data types.
Filed Under: fortranICEtype system