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

C++ OpenMP now handles ARRAY_TYPE array sections in mappers, not just pointers.

GCC now correctly handles C++ `ARRAY_TYPE` expressions, in addition to pointers, when mapping OpenMP array sections, fixing a bug introduced in a previous comm…

This commit fixes a bug in the OpenMP implementation for C++ that prevented array sections from being correctly mapped when represented as ARRAY_TYPE expressions, only allowing pointers. This oversight, introduced in a previous patch, caused compilation issues for valid C++ OpenMP code that uses array types directly. The fix ensures consistency with other parts of the compiler that already accommodate ARRAY_TYPE for array section handling.

In Details

The cxx_omp_map_array_section function in cp/semantics.cc is responsible for processing array sections within OpenMP declare mapper directives. This function was previously restricted to handling POINTER_TYPE expressions for the base of array sections, despite ARRAY_TYPE being permissible and encountered in valid code. This fix aligns cxx_omp_map_array_section with error-checking in handle_omp_array_sections_1 and code generation in build_array_ref, which both correctly accommodate ARRAY_TYPE expressions. This addresses an inconsistency introduced in `gcc-17-202-g3f8c7483112…

For Context

OpenMP is an extension to C, C++, and Fortran that lets you write programs that can run on multiple CPU cores, speeding up computationally intensive tasks. A key feature of OpenMP is controlling how data is transferred between the main computer's memory and specialized memory on accelerator devices (like GPUs), which is managed through "map clauses" and "mappers." When dealing with C++ arrays, the compiler usually sees them as either a pointer to the first element or a more structured ARRAY_TYPE representation. This change fixes a bug where the compiler wasn't correctly handling arrays represented as ARRAY_TYPE when using OpenMP 'declare mapper' directives for data transfer. It only recognized arrays if they were treated as simple pointers, leading to compilation errors for otherwise correct code. Now, the compiler properly understands both ways of representing arrays in this context, ensuring your C++ OpenMP code compiles as expected.

Filed Under: openmpc++bugfixarray-handling