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.unary.op] Fix usage of "result" #3945

Merged
merged 1 commit into from Dec 16, 2022

Conversation

languagelawyer
Copy link
Contributor

Do paragraphs 7-10 need similar fix or we fine with «the type of the result is X» when it means the type of the resulting prvalue?

@languagelawyer languagelawyer marked this pull request as draft April 18, 2020 06:58
@jensmaurer
Copy link
Member

Why exactly is a fix necessary here? [basic.lval] defines "result" of a glvalue and result of a prvalue, but the usage here seems to be "result of an operator".

source/expressions.tex Outdated Show resolved Hide resolved
source/expressions.tex Outdated Show resolved Hide resolved
@languagelawyer
Copy link
Contributor Author

languagelawyer commented Apr 18, 2020

Why exactly is a fix necessary here?

I find this confusing. Result is the object to which the lvalue refers. And the type of the result is the type of the object, which is not necessarily the same as the type of the lvalue.

@jensmaurer
Copy link
Member

Ah, dynamic type vs. static type.

It seems we need a clearer dictionary to talk about the static type of an operand / the result of the operation vs. the (dynamic) type of the result. Talking about "static" and "dynamic" type has its own set of ugliness, so what words should be in that dictionary? Once we have that clarified, we should fix all of [expr] to do the right thing.

What do you think about my reformulation?

@languagelawyer
Copy link
Contributor Author

What do you think about my reformulation?

I've used it, but changed the "The lvalue result ..." part.

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@languagelawyer languagelawyer marked this pull request as ready for review July 1, 2020 08:01
@zygoloid zygoloid added this to the C++23 milestone Sep 18, 2020
source/expressions.tex Outdated Show resolved Hide resolved
@zygoloid zygoloid added the changes requested Changes to the wording or approach have been requested and not yet applied. label Oct 18, 2020
@jensmaurer jensmaurer removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Dec 25, 2020
@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 17, 2021

Will take a look.

referring to the object or function to which the expression points. If
the type of the expression is ``pointer to \tcode{T}'', the type of the
result is ``\tcode{T}''.
Its operand shall be a prvalue of type ``pointer to \tcode{T}'',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensmaurer: is it a normative change to require that the operand be a prvalue, or was that previously implied by other wording?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The descriptions of most operators are unclear whether their operands are prvalues or lvalues.
Anyway, for the dereferencing operator, it's pelucidly clear that it takes a prvalue, always. Maybe the prior text saying "shall be a pointer to an object" could be interpreted as "shall be a pointer value...:", meaning a prvalue of pointer type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is largely inherited from C, where things aren't lvalues unless they're explicitly called out as lvalues.

The normative impact/question is whether there's an lvalue-to-rvalue conversion in something like *p. I agree that this can't really be anything else (after all, you need to "load" the pointer value before you can dereference it), but it just feels a tiny bit bold to establish such clarity editorially. Let's proceed optimistically, but let CWG know via email.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkoeppe In general, it is CWG1642.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@languagelawyer: thank you!

@languagelawyer languagelawyer marked this pull request as draft June 17, 2021 21:52
@languagelawyer languagelawyer marked this pull request as ready for review June 17, 2021 21:55
@tkoeppe
Copy link
Contributor

tkoeppe commented Aug 22, 2022

@jensmaurer I think we can take this, but I would appreciate if you took a final fresh core look at this and confirm that this is both correct and an improvement.

@jensmaurer
Copy link
Member

I think I want to have a CWG look at this, just to be on the safe side.

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Aug 22, 2022
@jensmaurer
Copy link
Member

Approved by CWG telecon 2022-08-26.

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 15, 2022

@jensmaurer Just to confirm, we can remove the cwg label?

@jensmaurer jensmaurer removed the cwg Issue must be reviewed by CWG. label Dec 16, 2022
@jensmaurer
Copy link
Member

Removed "cwg" label.

@tkoeppe tkoeppe merged commit 5ef31f3 into cplusplus:main Dec 16, 2022
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

4 participants