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

fortran: Move span declaration guess within array ref construction

Refactors Fortran array reference construction to improve span guessing.

The Fortran compiler has refactored the process of guessing the declaration for array spans. The logic for guessing the decl for a span has been moved from a function argument to within the build_array_ref function body. This change ensures that a better default declaration is guessed for span-addressed arrays, preventing regressions that occurred when a previously provided declaration interfered with the default guessing mechanism.

In Details

The gfc_get_dataptr_offset function previously passed the array declaration as an argument to build_array_ref for span guessing. This commit moves the default declaration guessing logic for span-addressed arrays entirely within build_array_ref. gfc_get_dataptr_offset now passes NULL_TREE, allowing build_array_ref to perform its default guess first, resolving a regression where the passed-in decl prevented a better guess and caused incorrect span addressing.

For Context
span addressing
A mechanism in Fortran for accessing array elements using a starting address and an extent (span), often used for pointers or dynamic arrays.
decl
In GCC's internal representation, a 'decl' (declaration) refers to an object representing a variable, function, type, or other identifier.
NULL_TREE
A special value in GCC's internal representation indicating the absence of a valid tree node, often used to represent null pointers or uninitialized values.
Filed Under: fortranrefactor