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

[basic.def.odr] p5 "appears as" is not defined and "named by" is a better choice #5533

Closed
xmh0511 opened this issue Jun 17, 2022 · 5 comments · Fixed by #5534
Closed

[basic.def.odr] p5 "appears as" is not defined and "named by" is a better choice #5533

xmh0511 opened this issue Jun 17, 2022 · 5 comments · Fixed by #5534

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jun 17, 2022

[basic.def.odr] p5 says

A variable is named by an expression if the expression is an id-expression that denotes it. A variable x whose name appears as a potentially-evaluated expression E is odr-used by E unless

The intent of what E is here refers to the id-expression naming the entity. "appear as" is not a defined meaning. It is better that we just say:

A variable is named by an expression if the expression is an id-expression that denotes it. A variable x named by a potentially-evaluated expression E is odr-used by E unless

It is more clear.

@jensmaurer
Copy link
Member

No, because it raises the question whether an unevaluated subexpression (e.g. sizeof) of a potentially-evaluated expression also fits "named by". (It clearly doesn't fit "appears as".)

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jun 17, 2022

No, because it raises the question whether an unevaluated subexpression (e.g. sizeof) of a potentially-evaluated expression also fits "named by". (It clearly doesn't fit "appears as".)

Why? Did you mean such as this example?

auto c = sizeof(T::x); 

The variable T:x is not named by the expression sizeof(T::x), it is just named by T::x that is an id-expression that denotes it. T::x is not potentially evaluated since it is the operand of sizeof. Could you please give a counterexample?

Furthermore, the wording about whether a function is odr-used in N495 has been changed from

A function whose name appears as a potentially-evaluated expression is odr-used if

to

A function is odr-used if it is named by a potentially-evaluated expression or conversion.

What's the difference if we apply a similar change for variables?

@jensmaurer
Copy link
Member

Agreed.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jun 17, 2022

#5534

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 8, 2022

@jensmaurer Could you take a look at #5534 then?

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 a pull request may close this issue.

3 participants