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

Fortran: Unwrap class containers from array descriptor element types.

Fortran compiler now correctly unwraps class containers for array descriptors, fixing incorrect element length calculations.

This commit resolves an issue in the Fortran compiler where class container types were incorrectly used as the element type for array descriptors. This led to erroneous initialization of the element length, impacting runtime behavior such as the ASSOCIATED intrinsic. The fix detects class containers and unwraps them before creating array descriptor types, ensuring correct element length calculation and accurate program execution.

In Details

The gfc_conv_expr_descriptor function in gcc/fortran/trans-array.cc is modified to handle cases where an array descriptor's element type is a class container. Previously, this scenario would lead to incorrect calculation of the element length, as the container type itself was used instead of its unwrapped form. The change detects such class containers and unwraps them, ensuring that the resulting array descriptor accurately reflects the element's size and type, as demonstrated by a new testcase for the ASSOCIATED intrinsic.

For Context
array descriptor
A data structure used by the Fortran compiler to represent arrays, containing information such as base address, element size, and array bounds.
class container
In Fortran, this likely refers to a type that encapsulates other data, potentially including arrays or other complex structures, used within a class definition.
ASSOCIATED intrinsic
A Fortran intrinsic function that checks the association status of a pointer or determines the target of a pointer, which relies on accurate array descriptor information.
Filed Under: fortrancompilertype system