GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fortran: Fixes ICE in DO CONCURRENT with DEFAULT(NONE) inside ASSOCIATE.

This commit resolves two bugs that caused an Internal Compiler Error (ICE) when a Fortran `DO CONCURRENT` loop with inline type-spec iterators was nested withi…

Two bugs in the Fortran compiler’s check_default_none_expr function, located in resolve.cc, led to an Internal Compiler Error (ICE) or segmentation fault. This specifically occurred when a DO CONCURRENT loop, utilizing inline type-specification iterators, was used inside an ASSOCIATE construct with the DEFAULT(NONE) attribute. The first bug involved incorrect namespace handling for ASSOCIATE bodies, while the second involved misidentifying shadow iterators. These fixes ensure correct compilation of complex Fortran constructs involving DO CONCURRENT, ASSOCIATE, and DEFAULT(NONE), improving the compiler’s robustness.

In Details

In Fortran, DO CONCURRENT specifies a loop that can be executed in parallel, ASSOCIATE creates a temporary alias for an expression or variable, and DEFAULT(NONE) mandates explicit declaration of all variables. Inline type-spec iterators (e.g., integer :: i = 1:10) introduce shadow variables. The check_default_none_expr function in resolve.cc is part of the semantic analysis phase, ensuring all variables are declared. Bug 1 concerned sym->ns->code incorrectly pointing to an EXEC_BLOCK node within an ASSOCIATE body instead of the DO CONCURRENT node, causing incorrect travers…

For Context

Compilers can sometimes crash or produce incorrect programs when encountering complex code. This commit fixes two specific problems in the Fortran compiler, preventing a crash called an 'Internal Compiler Error (ICE)' or a 'segmentation fault.' These crashes happened when a special type of loop, DO CONCURRENT (designed for parallel execution), was combined with another construct called ASSOCIATE (which temporarily renames variables) and a safety feature called DEFAULT(NONE) (which forces you to declare all variables). The bugs were deep within the compiler's logic for tracking variables and their locations in complex code structures. The fixes ensure that the compiler correctly understands how these features interact, allowing DO CONCURRENT loops to be safely used within ASSOCIATE blocks, making the compiler more stable and reliable for advanced Fortran programming.

Filed Under: fortrancompiler-bugparallel-programmingsemantic-analysis