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

Fix ICE in finalizer for nested derived type array components.

Corrected an internal compiler error when finalizing nested derived type array components.

This change resolves an internal compiler error (ICE) in the Fortran front-end’s finalization process. The error occurred when dealing with nested derived type array components due to an incorrect rank comparison when accessing the parent’s data. The fix ensures the ASSOCIATED check is applied to the base pointer, aligning with the expected behavior and preventing the ICE.

In Details

In Fortran, derived types can contain allocatable components, which require finalization (deallocation) when the type instance goes out of scope. For nested arrays of derived types, the finalization logic incorrectly determined the rank of the access path, leading to an ICE in gfc_get_descriptor_field. This patch corrects the logic by using the base pointer of the expression for the ASSOCIATED check, ensuring correct handling of array sections.

For Context
ICE
Internal Compiler Error. A condition where the compiler encounters an unrecoverable internal fault, halting its execution.
derived type
A user-defined composite data type in Fortran, similar to a struct in C, that can group variables of different types.
allocatable component
A component of a derived type whose memory allocation can be managed dynamically during runtime, allowing its size to change.
finalizer
A procedure or mechanism that performs cleanup actions, such as deallocating memory, when a variable or object goes out of scope or is no longer needed.
ASSOCIATED
A Fortran intrinsic function used to check if an allocatable variable or pointer is currently allocated or associated with a target.
Filed Under: fortrancompiler errorderived types