https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124331
Bug ID: 124331
Summary: [reflection] data member comparison mishap
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
Thanks to Dan K. for reporting & reducing this.
```
#include <meta>
template <typename T>
void f() {
constexpr auto ctx = std::meta::access_context::current();
static constexpr auto rng =
std::define_static_array(nonstatic_data_members_of(^^T, ctx));
static_assert(rng[0] == ^^T::mem);
};
struct S { int mem; };
auto force_instantiation = (f<S>, 0);
```
fails with
t.C:7:26: error: static assertion failed
7 | static_assert(rng[0] == ^^T::mem);
• the comparison reduces to ‘(^^S::mem == ^^S::mem)’
because compare_reflections gets:
(gdb) p lhs
$7 = <field_decl 0x7fffe63041e0 mem>
(gdb) p rhs
$8 = <component_ref 0x7fffe5f23b10>