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

Fixes coarray subobject cobound queries to prevent compiler ICEs.

Corrects how the Fortran compiler queries cobounds for coarray subobjects, resolving internal compiler errors.

This commit resolves several internal compiler errors (ICEs) related to querying the cobounds of a subobject of a coarray in Fortran. According to the F2018 standard, such subobjects are coarrays themselves unless accessed through specific selectors. The compiler was not correctly handling these cases, leading to errors when querying cobounds. The fixes ensure that the compiler correctly identifies and queries the cobounds of the coarray base symbol, even when accessing its subobjects, and properly handles cases where the declaration itself might have been previously rejected.

In Details

The Fortran compiler's handling of LCOBOUND(X%A) for coarrays was flawed. F2018:5.4.7(5) defines subobjects of coarrays as coarrays unless accessed via cosubscript, image selector, or allocatable/pointer component selector. The compiler failed to properly query cobounds in these scenarios, triggering ICEs. This change modifies simplify_cobound in fortran/simplify.cc to derive array specs from the base symbol, correctly handling CLASS coarrays. resolve.cc and trans-intrinsic.cc are updated to track corank and use a new strip_subobject_of_coarray function to ensure the correct des…

For Context
coarray
A Fortran language feature for parallel programming that allows procedures to access data residing on other images (processing units) directly. It enables SPMD (Single Program, Multiple Data) execution.
cobound
The lower and upper bounds of an array dimension. For coarrays, cobounds are related to the dimensions of the coarray's codimensions.
subobject
A component or part of a larger data structure. For example, if X is a derived type with component A, then X%A is a subobject.
ICE
Internal Compiler Error. An unrecoverable error condition within the compiler that halts compilation, often indicating a bug in the compiler itself.
F2018
Fortran 2018, the latest major revision of the Fortran standard, which includes features for parallel programming like coarrays.
Filed Under: fortrancompilercoarray