On Tue, Dec 16, 2025 at 10:48:40PM +0700, Jason Merrill wrote:
> > + else if (VAR_P (r) && DECL_ANON_UNION_VAR_P (r))
> > + return boolean_true_node;
>
> This surprises me, I'd think that an anon-union variable is equivalent to a
> member-access expression, but is not a class member itself, but perhaps it
> makes sense for reflection to blur that distinction. It would be nice if
> the standard were clear either way.
The artificial variable with the union type can be reflected through
members_of on the containing namespace. DECL_ANON_UNION_VAR_P is not that
through, it is what one gets from say ^^a after
static union { int a; long b; };
and that isn't a variable. Member-access expressions aren't one of the
https://eel.is/c++draft/basic.fundamental#17 categories, except for object
but I believe the only way to get an object is reflect_object.
And GCC agrees with clang++ on that, haven't tried EDG.
https://godbolt.org/z/Y36418a7x
Standard clarification would be appreciated.
Jakub