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

Fortran: Fix memory leak in pdt_86.f03 test case

Fixes a memory leak in the Fortran compiler's handling of derived types with allocatable components.

A memory leak in GCC’s Fortran frontend has been fixed, stemming from issues in handling derived types that contain allocatable components. The fix ensures that such types are correctly marked, preventing memory from being leaked during compilation. Additionally, a related test case was updated to verify the resolution of a separate issue where a non-PDT version of a compiled routine was leaking memory.

In Details

The Fortran frontend's type system was not correctly marking derived types with allocatable components when those components themselves were derived types. This commit ensures the gfc_pdt_has_allocatable_components flag is set appropriately. It also fixes an issue in gfc_resolve_ref where the initial type of a reference was not always set correctly when dealing with PDT instances.

For Context
PDT
Stands for 'Parameterized Derived Type'. In Fortran, these are derived types that can be parameterized, allowing for more flexible type definitions. They are a feature introduced in Fortran 2003.
Derived Type
A user-defined composite data type in Fortran, similar to 'struct' in C or 'class' in C++. It can contain components of various intrinsic or other derived types.
Allocatable Components
Components within a derived type that can be dynamically allocated and deallocated during program execution using the ALLOCATE and DEALLOCATE statements. This allows for flexible memory management.
Filed Under: fortranmemory leakcompiler