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.lval] Non-static member function designator is a prvalue CWG2458 #3262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

languagelawyer
Copy link
Contributor

[expr.ref]/6.3.2:

if E1.E2 refers to a non-static member function and the type of E2 is “...”, then E1.E2 is a prvalue. The expression designates a non-static member function.

@zygoloid
Copy link
Member

zygoloid commented Oct 6, 2019

Hm, non-static member functions really don't fit into the value category taxonomy well at all. We do seem to be consistent, at least; [expr.prim.id.qual]/2 also says that Class::f is a prvalue if f is a non-static member function.

I don't like complicating the definition of lvalue with this quirk (and note that we'd need to complicate the definition of prvalue with it too), so since it makes no observable difference, I'd like to first send this to CWG to see if we can reclassify non-static member function expressions as lvalues. That should simplify the wording: we get a simpler rule here, we get a simpler rule in [expr.prim.id.qual]/2, we get a simpler rule in [expr.ref] (all of /6.3 produces an lvalue). And we get a simpler rule for the & operator: it always wants an lvalue as its operand.

We may still want a change here if we go that route:

A \defn{glvalue} is an expression whose evaluation determines the identity of an object, bit-field, or function, or both an object and a non-static member function.

@zygoloid zygoloid added the cwg Issue must be reviewed by CWG. label Oct 6, 2019
@languagelawyer
Copy link
Contributor Author

languagelawyer commented Oct 6, 2019

@zygoloid:

and note that we'd need to complicate the definition of prvalue with it too

Why? [expr.ref]/6.3.2 says:

The expression designates a non-static member function. The expression can be used only as the left-hand operand of a member function call

And the definition of prvalue says:

A prvalue is an expression whose evaluation ... computes the value of an operand of an operator

I've thought this "computes the value of an operand of an operator" is enough to cover non-static member function designators usage. ("value" does not apply well, though).

UPD: Ah, you mean that E1.E2 denotes (or rather should denote) both a non-static member function and an object. Then prvalue definition would indeed need a fix.
However, currently [expr.call] is worded as if it decomposes E1.E2 and looks at E1 (the object expression).

@languagelawyer
Copy link
Contributor Author

I'd like to first send this to CWG to see if we can reclassify non-static member function expressions as lvalues

Should I send this?

@jensmaurer
Copy link
Member

@jensmaurer jensmaurer changed the title [basic.lval] Non-static member function designator is a prvalue [basic.lval] Non-static member function designator is a prvalue CWG 2458 Feb 16, 2021
@jensmaurer jensmaurer added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label Feb 16, 2021
@jensmaurer jensmaurer added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Jun 14, 2021
@jensmaurer jensmaurer changed the title [basic.lval] Non-static member function designator is a prvalue CWG 2458 [basic.lval] Non-static member function designator is a prvalue CWG2458 Jul 5, 2021
@jensmaurer
Copy link
Member

@languagelawyer: Now that CWG2458 has landed, could you please update the pull request accordingly?

@jensmaurer jensmaurer added changes requested Changes to the wording or approach have been requested and not yet applied. and removed cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. labels Jul 5, 2021
@languagelawyer
Copy link
Contributor Author

languagelawyer commented Jul 6, 2021

@jensmaurer rate the ugliness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied. needs rebase The pull request needs a git rebase to resolve merge conflicts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants