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

fortran: Fix simply contiguous for polymorphic arrays [PR127613]

Fortran 'simply contiguous' check now correctly handles polymorphic arrays.

The Fortran compiler’s ‘simply contiguous’ predicate has been corrected to accurately handle polymorphic arrays. Previously, it incorrectly evaluated the predicate for a polymorphic contiguous array because it relied on the last component of a class container’s data reference, which lacks the contiguous attribute. The fix ensures that the predicate properly tracks type information and accesses the correct attributes, distinguishing between polymorphic and non-polymorphic references, and correctly identifying contiguous polymorphic arrays.

In Details

This commit addresses PR127613 by refining the gfc_is_simply_contiguous predicate in the Fortran frontend. The predicate incorrectly returned false for polymorphic contiguous arrays because it was tracking the last component reference in a data reference chain. For a polymorphic array, this last component is the _data component of its class container, which holds the pointer attribute but not the contiguous attribute itself (which resides at the class container level). The fix modifies the walk to retain access to the class container's attributes and array type information, preventing p…

For Context
simply contiguous
A Fortran attribute indicating that an array or an array section is stored in contiguous memory locations, without any gaps. This is important for performance and for interoperability with other languages or libraries.
polymorphic array
In Fortran, an array whose elements can be of different, but related, dynamic types. This is typically achieved through inheritance in type extension.
class container
In Fortran, a derived type that holds polymorphic components. It represents an object whose dynamic type can change.
assumed-shape dummy
A procedure argument in Fortran that receives an array whose dimensions are determined by the calling argument, not fixed in the procedure definition.
pointer attribute
In Fortran, a type attribute that indicates a variable is a pointer, capable of holding the address of another variable.
Filed Under: fortranbugfixcontiguous