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

Fortran passes arrays with descriptors for non-contiguous TARGET dummies

Fortran now uses descriptors for non-contiguous array actual arguments passed to TARGET or POINTER dummies.

A fix for Fortran addresses issues with array actual arguments that have non-contiguous elements when passed to TARGET or POINTER dummy arguments. Previously, these were incorrectly copied, leading to stale pointers. The compiler now passes a descriptor for such arrays, ensuring correct pointer association and only copying data if necessary.

In Details

When an actual array argument has elements spaced by more than their size (e.g., a CLASS array or derived-type component), passing it to a TARGET or POINTER dummy previously caused incorrect copy-in/out, invalidating dummy pointers. This change ensures such arguments are passed with a descriptor that correctly represents their span and element type, addressing PR53800.

For Context
TARGET dummy
In Fortran, a dummy argument that is declared with the TARGET attribute, indicating it can be the target of a POINTER.
POINTER dummy
In Fortran, a dummy argument declared as a POINTER. It can be associated with a TARGET or another POINTER.
descriptor
A data structure that describes an array, typically containing its base address, element type, size, and shape (e.g., bounds and strides). Fortran uses descriptors to handle arrays with complex layouts.
stale pointers
Pointers that reference memory locations that are no longer valid or have been reallocated for different data, leading to undefined behavior.
host association
A Fortran mechanism where contained procedures can access variables from their containing procedures (hosts).
Filed Under: fortranarray passingpointer