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

fortran: Make span_addressed_array return a boolean

Simplifies Fortran array handling by making `span_addressed_array` a boolean predicate.

The Fortran compiler has refactored the span_addressed_array function to return a boolean value, clarifying its purpose as a predicate. Previously, it could return either NULL_TREE or its argument, leading to ambiguity in boolean contexts. This change separates the predicate logic from the value selection, improving code clarity and making the function’s intent more explicit, especially in gfc_get_dataptr_offset.

In Details

The span_addressed_array function in trans-array.cc previously returned either NULL_TREE or its input array argument, creating ambiguity when used in boolean contexts. This commit renames it to is_span_addressed_array and makes it return bool. The logic for selecting NULL_TREE or the input array is now handled separately in gfc_get_dataptr_offset, cleaning up the usage in functions like gfc_get_array_span and gfc_conv_array_ref.

For Context
span_addressed_array
A Fortran compiler internal function that checks if an array is accessed using span addressing.
predicate
In programming, a predicate is a function that returns a boolean value (true or false), typically used to test a condition.
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