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

[dcl.init.ref]/5 Prevent prvalue type adjustment CWG2481 #2657

Closed
wants to merge 1 commit into from

Conversation

languagelawyer
Copy link
Contributor

@languagelawyer languagelawyer commented Jan 27, 2019

Fresh prvalues could fall prey to [expr.type]/2: "If a prvalue initially has the type “cv T”, where T is a cv-unqualified non-class, non-array type, the type of the expression is adjusted to T prior to any further analysis."

I've also rewritten the sentence in the semantic line breaks style.

However, this would be a wrong fix if it is decided to restore the "no cv-qualified non-class non-array prvalues" status quo (see #2655).

See CWG2481

@languagelawyer
Copy link
Contributor Author

The issue was spotted in https://stackoverflow.com/q/54381791/9585016

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 3, 2019
the initializer expression is implicitly converted to a prvalue
of type ``\cvqual{cv1} \tcode{T1}''.
the initializer expression is implicitly converted to a prvalue of type \tcode{T1},
then the type of the resulting prvalue is adjusted to ``\cvqual{cv1} \tcode{T1}''.
Copy link
Member

Choose a reason for hiding this comment

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

Seems clunky to convert to one type then adjust to another. There's also a risk that cv-qualifiers in the destination type of the implicit conversion could matter in some contexts. How about:

Otherwise, the initializer expression is implicitly converted to a prvalue of type ''cv1 T'' and the temporary materialization conversion is immediately applied; the reference is bound to the result of this conversion.

or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think that it is clear that "immediately" means [expr.type]/2 does not apply?

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Jun 5, 2019
@jensmaurer
Copy link
Member

jensmaurer commented Jun 5, 2019

Editorial meeting: Use Richard's suggestion and add a note saying that the cv-removal for scalar prvalues is not done before the materialization.

@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Jun 6, 2019
@jensmaurer jensmaurer changed the title [dcl.init.ref]/5 Prevent prvalue type adjustment [dcl.init.ref]/5 Prevent prvalue type adjustment CWG2481 May 24, 2021
@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Jun 15, 2021
@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 23, 2021

@languagelawyer: could you please rebase this and apply the above suggestion?

@languagelawyer
Copy link
Contributor Author

This was fixed differently fc923d6

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

5 participants