https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123642
Bug ID: 123642
Summary: [reflection] error in case of splice with reflection
of an anonymous union member
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: valentin.yukhymenko at gmail dot com
Target Milestone: ---
Code like this fails to compile.
```
struct foo {
int i;
union {
int a;
long b;
};
};
int main() {
constexpr foo bar { .i = 11, .a = 1 };
static_assert(bar.a == 1);
static_assert(bar.[:^^foo::a:] == 1);
// ERROR: class 'foo' not derived from '(anonymous union at <source>:3:3)'
static_assert(bar.*&[:^^foo::a:] == 1);
// NO ERROR
}
```
https://compiler-explorer.com/z/jYdWWTGTs