GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
c++

C++ name mangling corrected for type alias reflections.

Fixes a compiler ICE when mangling type aliases for reflection by using the correct name writing function.

This commit addresses an internal compiler error (ICE) related to C++ name mangling for type alias reflections. The issue occurred because the compiler was using an inappropriate function to write the name of a type alias that referred to an unnamed type. The fix ensures that the source name of the type alias itself is used for mangling, resolving the ICE and improving the handling of reflection for such constructs.

In Details

The write_unqualified_name function in mangle.cc incorrectly handled type aliases pointing to unnamed types, leading to an ICE in nested_anon_class_index. This change modifies write_reflection to use maybe_write_module and write_source_name for type aliases, ensuring the alias's own name is used for mangling rather than attempting to mangle the underlying unnamed type.

For Context
name mangling
The process of encoding type and namespace information into a function or symbol name. This is essential in C++ to differentiate between functions with the same name but different parameter lists (overloading) or in the presence of namespaces and templates.
type alias
A name given to an existing type. In C++, this can be done using typedef or using. The compiler needs to correctly represent these aliases, especially when they refer to complex or unnamed types.
reflection
The ability of a program to examine and modify its own structure and behavior at runtime. In the context of C++, this can involve introspecting types and their properties.
ICE
Internal Compiler Error. This signifies a bug within the compiler itself, where an unexpected condition or state is encountered, causing it to halt.
Filed Under: c++compiler bugname mangling