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

Fix ICE in variadic using-declaration with conversion functions.

Fixes an internal compiler error (ICE) when using variadic using-declarations with conversion functions due to incorrect argument rewriting.

The compiler crashed when encountering a variadic using-declaration combined with a conversion function. The issue arose because the compiler was rewriting arguments incorrectly during template substitution, leading to unexpected identifier node types. The fix involves copying the arguments before modification to prevent unintended side effects. This issue was reported in PR125284 and PR125333.

In Details

When substituting variadic using-declarations, tsubst_decl with USING_DECL calls tsubst_pack_expansion. The arguments are rewritten using make_conv_op_name, which modifies the original arguments passed to tsubst_pack_expansion. This leads to an ICE when processing a second using-declaration, as the TEMPLATE_TYPE_PARM gets an identifier node for __conv_op which is not a TYPE_P. Copying targs before modification fixes the issue. Interaction with template instantiation is at play here.

For Context

C++ templates allow writing code that works with different data types without having to duplicate the code. Variadic templates extend this to handle a variable number of template arguments. A 'using-declaration' lets you introduce names from a base class or namespace into the current scope. This commit fixes a bug that occurred when using a variadic using-declaration with a conversion function (a special member function that defines how to convert an object of one class type to another) . The fix ensures that template arguments are correctly processed during compilation.

Filed Under: c++templatesbugfix