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

[expr.prim.lambda.capture] Improve wording on anonymous unions in lambda captures #6171

Closed
wants to merge 1 commit into from

Conversation

lprv
Copy link
Contributor

@lprv lprv commented Mar 11, 2023

The restrictions in [expr.prim.lambda.capture] should refer to anonymous union variables instead of their members, as the latter aren't local entities and can't be captured anyway.

@jensmaurer
Copy link
Member

What is an "anonymous union variable"? Why would it be captured when attempting to capture a member of an anonymous union?

@lprv
Copy link
Contributor Author

lprv commented Mar 12, 2023

'Anonymous union variable' is defined in [class.union.anon].

My reasoning here is that non-static data members aren't variables, meaning they can't be (individually) captured. But now that I look at it again, I realize [expr.prim.id.general]/2.2 does not explicitly say that the anonymous union variable in the implied class member access is named with an (invented) id-expression, which is needed for things like [basic.def.odr]/5 and [expr.prim.lambda.capture]/7 to work under this intepretation. So it looks like more changes are needed here, and I'm not entirely sure in which direction (either make the change to [expr.prim.id.general]/2.2, or specify that members of anonymous union variables are themselves local entities); either way, this is probably not editorial.

@jensmaurer
Copy link
Member

jensmaurer commented Mar 12, 2023

Since members of anonymous union variables are not local entities (as you correctly observe), they can't be captured to start with.

I think the correct fix is to remove both mentions of anonymous union members (normative duplication) and add a note after [expr.prim.lambda.capture] p1, saying that members of anonymous unions cannot be captured because they are not local entities (xref).

@lprv
Copy link
Contributor Author

lprv commented Mar 13, 2023

Yes, but the union also needs to be odr-used by an expression naming its member.

Relatedly, members of anonymous unions don't belong to a namespace scope, but [basic.link]/3.3 claims otherwise. And [basic.link]/13 through /15 do not account for anonymous unions either.

@lprv lprv closed this Mar 27, 2023
@lprv lprv deleted the expr.prim.lambda.capture branch March 27, 2023 20:00
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

Successfully merging this pull request may close these issues.

None yet

2 participants