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

Fortran: Emit static initializers for ISO_FORTRAN_ENV array constants in procedures.

Fixes initialization of ISO_FORTRAN_ENV array constants used within Fortran procedures.

An issue in the Fortran compiler caused array constants from ISO_FORTRAN_ENV to be uninitialized when used within procedures. Although these constants were marked TREE_STATIC for inlining, their static initializers were only generated for main programs or modules. This fix ensures that initializers are emitted regardless of the enclosing scope, correctly initializing these array constants within procedures.

In Details

The gfc_get_symbol_decl function in fortran/trans-decl.cc has been updated to unconditionally emit static initializers for intrinsic array parameters, including those from ISO_FORTRAN_ENV. Previously, this emission was conditional on the symbol's namespace belonging to the main program or a module, leading to uninitialized arrays when such constants were used inside procedures.

For Context
ISO_FORTRAN_ENV
A standard Fortran module that provides intrinsic constants and variables for use in numerical and environmental operations, such as array indexing and bit manipulation.
TREE_STATIC
An internal GCC representation indicating that a variable or constant should have static storage duration, meaning it exists for the lifetime of the program and is initialized once.
static initializer
The initial value assigned to a variable or constant with static storage duration when the program begins execution.
Fortran procedure
A subroutine, function, or program unit in Fortran that performs a specific task or calculation.
Filed Under: fortrancompiler bugfixinitialization