Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An anonymous union member is not a non-static data member on grammar #4939

Open
xmh0511 opened this issue Sep 26, 2021 · 2 comments
Open

An anonymous union member is not a non-static data member on grammar #4939

xmh0511 opened this issue Sep 26, 2021 · 2 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 26, 2021

[class.mem.general] p3 explicitly says

A data member is a non-function member introduced by a member-declarator.

While [class.union.anon] p1 says

A union of the form union { member-specification } ; is called an anonymous union; it defines an unnamed type and an unnamed object of that type called an anonymous union member if it is a non-static data member or an anonymous union variable otherwise.

Such two rules contradict each other. Maybe, we should say

An anonymous union behaves as if it were replaced by

union { member-specification } unnamed;

@xmh0511 xmh0511 changed the title Anonymous union member is not a non-static data member on grammar An anonymous union member is not a non-static data member on grammar Sep 26, 2021
@jensmaurer
Copy link
Member

The fall-out for that approach is a bit wide in scope. I think just extending the sentence in [class.mem.general] p3 for the anonymous union case is good enough.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Sep 26, 2021

Agree, that would be a minimal modification that wouldn't cause other conflictions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants