Skip to content

CWG2657 [dcl.init.ref] cv-qualification adjustment when binding reference to temporary #172

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

Closed
t3nsor opened this issue Nov 11, 2022 · 1 comment · Fixed by cplusplus/draft#6906

Comments

@t3nsor
Copy link

t3nsor commented Nov 11, 2022

Full name of submitter: Brian Bi

Reference (section label): [dcl.init.ref]

Issue description: CWG 2481 was resolved by clarifying that the temporary object in p5.4.2 is cv-qualified if the reference being initialized is cv-qualified. However, this is not the right bullet point for the example given,

constexpr const int &r = 42;

Such an initialization would actually use bullet 5.3.1 instead. (5.4.2 would be used if the initializer were, for example, 3.14.) We therefore need to make a similar clarification in bullet 5.3, and ideally using the same language.

Suggested resolution: In p5.3, replace the sentence "If the converted initializer is a prvalue, its type T4 is adjusted to type "cv1 T4" (7.3.6) and the temporary materialization conversion (7.3.5) is applied." with:

"If the converted initializer is a prvalue, let its type be denoted by T4; the temporary materialization conversion (7.3.5) is applied, considering the type of the prvalue to be "cv1 T4"."

Although I copied the language from bullet 5.4.2, I have concerns about it; to me, it's still not crystal clear that the decay does not intervene prior to the operation of the temporary materialization conversion. To clarify it, I also propose adding examples. Add the following line to the end of example 5:

const int& r2 = 0;  // binds directly to temporary of type `const int`

In example 6, after "rcd2 refers to temporary with", insert " type const double and".

@jensmaurer jensmaurer changed the title [section.label] cv-qualification adjustment when binding reference to temporary [dcl.init.ref] cv-qualification adjustment when binding reference to temporary Nov 27, 2022
@jensmaurer
Copy link
Member

CWG2657

@jensmaurer jensmaurer changed the title [dcl.init.ref] cv-qualification adjustment when binding reference to temporary CWG2657 [dcl.init.ref] cv-qualification adjustment when binding reference to temporary Nov 27, 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 a pull request may close this issue.

2 participants