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

Deduction of return type from returned expression is unclear #371

Closed
zygoloid opened this issue Aug 22, 2014 · 2 comments
Closed

Deduction of return type from returned expression is unclear #371

zygoloid opened this issue Aug 22, 2014 · 2 comments

Comments

@zygoloid
Copy link
Member

DIS 14882:2014 NB comment JP 07:

In 7.1.6.4p7: In the sentence, “When a variable…type of its specifier”, we think specification for function return type deduction is unclear, because the term "initializer" is not directly related to return statement.

Proposed change

Change to: (e.g.)

the deduced return type is determined from the type of expression specified for the return statement.

@zygoloid
Copy link
Member Author

Per [dcl.init]p15, initialization is performed by a return statement. The notion of there being an initializer in this context is used in other parts of the standard (for instance, [dcl.init]p17). The proposed change is not correct, because the initializer may be a braced-init-list, which is not an expression.

Alternative proposed change:

When a variable declared using a placeholder type is initialized, or a return statement occurs inis used to initialize the object or reference returned by a function declared with a return type that contains a placeholder type, the deduced return type or variable type is determined from the type of itsthe initializer.

@jensmaurer
Copy link
Member

This is now [dcl.type.auto.deduct] and seems to have been rewritten such that the questionable phrase is gone.

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

2 participants