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

Fortran: Ensure dummy array span is created in owning function

Fixes an ICE in the Fortran frontend when a dummy array's span variable was incorrectly placed.

The Fortran compiler’s translation process incorrectly created the ‘span’ variable for a dummy array within a contained procedure, rather than its owning function. This led to an internal compiler error (ICE) when the dummy array was first referenced from the contained procedure. The fix ensures the span variable is correctly associated with the host function, resolving the ICE and enabling proper handling of these array declarations.

In Details

In the GCC Fortran frontend (gfc), when a procedure contains another procedure (a contained procedure), variables declared in the host procedure are accessible to the contained one. For 'span-addressed' dummy arrays, a 'span' variable is created to manage the array's bounds. This commit corrects gfc_build_dummy_array_decl in trans-decl.cc to use create_index_var to allocate the span variable within the context of the owning function, rather than the contained procedure, preventing an ICE related to symbol visibility and scope.

For Context
dummy array
In Fortran, an array argument passed to a procedure. It acts as a placeholder for an array provided by the caller.
span
In the context of Fortran's TARGET attribute for arrays, the 'span' refers to metadata that describes the array's bounds and characteristics, used for runtime management.
contained procedure
A procedure (like a subroutine or function) defined within another procedure in Fortran.
ICE
Internal Compiler Error. A severe error encountered during compilation that prevents the compiler from continuing.
Filed Under: fortrancompiler