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

C++/reflection: Use OPAQUE_TYPE for std::meta::info to fix LTO.

C++ reflection's std::meta::info type is now represented using OPAQUE_TYPE, resolving LTO issues and a related bug.

This change updates the representation of std::meta::info in C++ reflection from LANG_TYPE to OPAQUE_TYPE. The previous LANG_TYPE representation caused issues with Link-Time Optimization (LTO) and failed to be marked correctly, leading to crashes and bugs. Using OPAQUE_TYPE, which was introduced for other types, resolves these problems by providing a more suitable representation for this type.

In Details

The C++ reflection implementation previously used LANG_TYPE for std::meta::info. This commit switches to OPAQUE_TYPE (introduced in GCC 11 for PowerPC MMA types) in gcc/cp/reflect.cc and related tree handling (gcc/tree.cc, gcc/tree.def). This resolves PR c++/126017 (LTO streaming crashes) and PR c++/127856 by correctly handling placeholder types and enabling proper type discrimination, while also updating DWARF output (gcc/dwarf2out.cc) and pretty-printing (gcc/cp/cxx-pretty-print.cc).

For Context
LTO
Link-Time Optimization. A compiler optimization technique that performs optimizations on the entire program at link time, rather than on individual object files. This allows for more aggressive interprocedural optimizations.
OPAQUE_TYPE
A GCC tree node type used to represent types whose internal structure is not fully known or relevant at a particular stage of compilation. It was introduced for specific target types and is now used for C++ reflection's std::meta::info.
LANG_TYPE
A GCC tree node type historically used to represent language-specific types. Its use for std::meta::info proved problematic for LTO and type handling.
std::meta::info
A C++ standard library type (part of C++26 reflection features) that provides runtime information about types, functions, and other program entities.
TREE_TYPE
A fundamental data structure in GCC's internal representation (GIMPLE and GENERIC) used to represent various language constructs, including types.
Filed Under: c++reflectionltocompiler bug