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

20.10.6 [meta.rel] says "return-statement" #445

Closed
jwakely opened this issue Feb 23, 2015 · 5 comments
Closed

20.10.6 [meta.rel] says "return-statement" #445

jwakely opened this issue Feb 23, 2015 · 5 comments
Assignees

Comments

@jwakely
Copy link
Member

jwakely commented Feb 23, 2015

Should probably be "return statement"

@zygoloid
Copy link
Member

I think you mean this, from p4:

Access checking is performed as if in a context unrelated to To and From. Only the validity
of the immediate context of the expression of the return-statement (including conversions to the return type) is considered. [Note: The evaluation of the conversion can result in side effects such as the instantiation of class template specializations and function template specializations, the generation of implicitly-defined functions, and so on. Such side effects are not in the “immediate context” and can result in the program being ill-formed.]

This is wrong in quite a few ways ("evaluation" and "side effect" are defined to mean something completely different from what this note is talking about, there is no such thing as a return-statement, the "as if" is noise since it's already implied for all rules in the standard, ...). How about this:

Access checking is performed in a context unrelated to To and From. Only the validity of the immediate context of the expression in the return statement (including the initialization of the returned object or reference) is considered. [Note: The initialization can result in effects such as the instantiation of class template specializations and function template specializations, the generation of implicitly-defined functions, and so on. Such effects are not in the “immediate context” and can result in the program being ill-formed.]

The bogus "side effects" / "evaluation" wording also appears in [temp.deduct]/8 and Table 49 in [meta.unary.prop]; we should either fix it everywhere, or preferably just refer back to [temp.deduct] for the implications of "immediate context". It'd be good to make [temp.deduct] actually define this rather than hand-wave...

@zygoloid zygoloid changed the title 20.10.6 [meta.rel] says "return expression" 20.10.6 [meta.rel] says "return-statement" Feb 24, 2015
@jwakely
Copy link
Member Author

jwakely commented Feb 25, 2015

(Oops, just deleted my comment instead of editing it)

I actually meant this text earlier in the paragraph, between the two code blocks:

only if the return expression in the following code would be well-formed,

But I agree with the other problems you spotted, and your suggested fixes.

@jensmaurer
Copy link
Member

The "immediate context" phrasing, including the note, has spawned throughout [meta], it seems.

jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 9, 2016
Drop the duplicated notes explaining ill-formed specializations
in other than the immediate context.

Fixes cplusplus#445.
@jensmaurer jensmaurer self-assigned this Dec 12, 2016
jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 13, 2016
Drop the duplicated notes explaining ill-formed specializations
in other than the immediate context.

Fixes cplusplus#445.
Fixes cplusplus#272.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 14, 2016
Drop the duplicated notes explaining ill-formed specializations
in other than the immediate context.

Fixes cplusplus#445.
Fixes cplusplus#272.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 15, 2016
Drop the duplicated notes explaining ill-formed specializations
in other than the immediate context.

Fixes cplusplus#445.
Fixes cplusplus#272.
@jensmaurer
Copy link
Member

The "immediate context" concerns are covered by LWG 2290 "Top-level "SFINAE"-based constraints should get a separate definition in Clause 17".

@jensmaurer
Copy link
Member

#1252 fixes [temp.deduct] to avoid "side effect" and "evaluation".

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

No branches or pull requests

3 participants