GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fortran OpenMP SIMD constructor/destructor hooks fixed.

Corrected OpenMP SIMD constructor and destructor behavior for body-local declarations in Fortran.

This commit rectifies issues with how Fortran handles OpenMP SIMD constructs for variables declared locally within the SIMD body. Previously, the compiler incorrectly applied user-level private variable logic to these body-local declarations, leading to assertion failures and memory issues. The changes ensure that the default constructor and destructor hooks correctly do nothing for these specific declarations, preventing errors and ensuring proper initialization and finalization.

In Details

Gimplify in GFortran implicitly assigns an OpenMP private clause to addressable declarations local to a SIMD body. The original Fortran OpenMP clause handlers treated these as user-declared private variables. This led to incorrect behavior: the default constructor would assert on allocatable components, and the destructor would attempt to free memory for CLASS temporaries when it was unnecessary. This patch modifies the gfc_omp_clause_default_ctor and gfc_omp_clause_dtor to be no-ops for these specific body-local private declarations when they lack an outer reference, relying on t…

For Context
OpenMP SIMD
An OpenMP directive that allows the compiler to apply SIMD (Single Instruction, Multiple Data) vectorization to loops, enabling parallel execution of loop iterations on multiple data elements simultaneously.
Gimplify
A compiler pass in GCC that transforms high-level language constructs into a lower-level intermediate representation called GIMPLE.
allocatable
A Fortran attribute that allows an array or derived type component to be dynamically allocated and deallocated during program execution.
CLASS temporary
A temporary variable in Fortran used to hold values of polymorphic types (types that can be extended).
Filed Under: fortranopenmpsimd