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

C++ Modules: Handle typedef struct { } A with reflection

Fixes module merging for typedefs to unnamed types when reflection is enabled.

GCC’s C++ module merging had issues with typedefs to unnamed types (e.g., typedef struct { } A) when reflection was enabled. A recent change modified the representation of such typedefs, and this patch updates the module merging logic to handle this new representation correctly. This ensures that the unnamed decl is properly handled, even though it isn’t visible to name lookup, resolving a merge failure. New test cases are added.

In Details

The GCC C++ frontend's module implementation (module.cc) now correctly merges typedefs to unnamed types when the -freflection option is used, addressing a regression introduced by r16-7903. The patch specifically handles the case where the unnamed type declaration exists but is not visible to name lookup, ensuring that the merge proceeds correctly.

For Context

C++ modules are a way to organize code into reusable units, improving dependency management. Reflection is a feature that allows a program to inspect and modify its own structure and behavior at runtime. When modules and reflection are combined, the compiler needs to handle the interaction between these features correctly, including the merging of type declarations across module boundaries.

Filed Under: c++modulesreflectionbugfix