Skip to content

[class.union.anon] Correct definition of union-like class - #9281

Open
TymianekPL wants to merge 1 commit into
cplusplus:mainfrom
TymianekPL:redundant-union-or-class
Open

[class.union.anon] Correct definition of union-like class#9281
TymianekPL wants to merge 1 commit into
cplusplus:mainfrom
TymianekPL:redundant-union-or-class

Conversation

@TymianekPL

Copy link
Copy Markdown
Contributor

There is a redundant union or, as all unions are classed.

-  union-like class is a union or a class [...]
+  union-like class is a class [...]

@eisenwave eisenwave added the P3-Other Triaged issue not in P1 or P2 label Aug 29, 2026
@eisenwave

eisenwave commented Aug 29, 2026

Copy link
Copy Markdown
Member

I don't think there's something objectively wrong here. "union" is a defined term in https://eel.is/c++draft/class.union.general#def:union

Saying "union or class" is clunky though. My preference is "class type", if we want a change, but just "class" is also fine by me.

@TymianekPL

Copy link
Copy Markdown
Contributor Author

I suppose a synonym term for "Correct" could be used? But I'm not sure which one reflects the intent better...

@Halalaluyafail3

Copy link
Copy Markdown
Contributor

I thought it was meant to be read like "A union-like class is a union or (a class that has an anonymous union as a direct member)." rather than "A union-like class is (a union or a class) that has an anonymous union as a direct member.".

@TymianekPL

Copy link
Copy Markdown
Contributor Author

Okay turns out that union-like class is just a leftover from old wording that doesn't exist anymore

Should we remove this definition as it's unused?

@eisenwave

eisenwave commented Aug 30, 2026

Copy link
Copy Markdown
Member

I thought it was meant to be read like "A union-like class is a union or (a class that has an anonymous union as a direct member)." rather than "A union-like class is (a union or a class) that has an anonymous union as a direct member.".

Oh yeah, that reading makes much more sense.

Perhaps it could be clarified by "is a union or is a class"

@eisenwave

Copy link
Copy Markdown
Member

Okay turns out that union-like class is just a leftover from old wording that doesn't exist anymore

Should we remove this definition as it's unused?

At the end of the paragraph, it says

At most one variant member of a union may have a default
member initializer.

So the "union-like class" term may not be used elsewhere, but it's used internally.

@TymianekPL

Copy link
Copy Markdown
Contributor Author

Oh right true, interesting...
I'm still unsure about how one should parse this sentence still. Maybe we can come up with better wording to say this intent? The current one is a bit ambiguous 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3-Other Triaged issue not in P1 or P2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants