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

C++/reflection: Fixes for comparing reflections [PR125208]

Fixes bugs in comparing C++ reflections, including a crash and incorrect alias comparison.

This commit fixes two bugs in the C++ reflection implementation related to comparing reflections. The first bug was a crash in cp_tree_equal when comparing reflections with binfos. The second bug was in compare_reflections when comparing two aliases, where it incorrectly fell back to same_type_p. The fix ensures that comparing aliases correctly distinguishes between them.

In Details

The commit resolves issues in reflect.cc and tree.cc related to C++ reflection comparisons. It addresses a crash in cp_tree_equal when handling binfos within reflections and corrects the logic in compare_reflections to properly compare aliases. Specifically, it avoids using same_type_p when comparing aliases to ensure distinct alias types are correctly differentiated.

For Context

C++ reflection is a feature that allows programs to inspect and manipulate the structure of types at runtime. This commit focuses on the comparison of reflection objects, which represent types and their properties. The fixes ensure that the comparison logic correctly handles different kinds of types, including aliases, which are alternative names for existing types.

Filed Under: c++reflectionbugfix