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

C++ handles array-to-pointer decay in build_invoke for traits.

GCC now correctly handles array-to-pointer decay in `build_invoke` for C++ traits like `is_invocable`.

This commit resolves an issue in C++’s build_invoke function where array types were not treated consistently with pointer types concerning decay. This inconsistency caused problems for type traits such as std::is_invocable when using the non-intrinsic versions, leading to compilation failures. The change ensures that array types are now handled similarly to pointer types in build_invoke, accommodating the standard array-to-pointer decay.

In Details

The build_invoke function in GCC's C++ frontend, specifically within method.cc, was not correctly handling ARRAY_TYPE in a way consistent with array-to-pointer decay when invoked indirectly, such as via type traits like std::is_invocable. When __is_invocable was used as a built-in trait, it worked because it bypassed this issue. However, when _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS was defined, leading to the use of std::is_invocable and its underlying mechanisms, build_invoke's treatment of ARRAY_TYPE caused failures. This patch modifies build_invoke to treat ARRAY_TYPE syno…

For Context
array-to-pointer decay
In C and C++, an array name used in an expression often automatically converts (decays) into a pointer to its first element.
type traits
A C++ feature that allows querying properties of types at compile time, often used for metaprogramming and generic programming.
is_invocable
A C++ type trait that checks whether a given type (e.g., a callable object) can be called with a specific set of arguments.
build_invoke
An internal GCC function responsible for constructing the necessary internal representation for function calls, including those generated for C++ template metaprogramming.
Filed Under: c++template metaprogramming