Skip to content

Deduction of return type from returned expression is unclear #371

Closed
@zygoloid

Description

@zygoloid

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.

Activity

zygoloid

zygoloid commented on Aug 22, 2014

@zygoloid
MemberAuthor

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

jensmaurer commented on Nov 13, 2016

@jensmaurer
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zygoloid@jensmaurer

        Issue actions

          Deduction of return type from returned expression is unclear · Issue #371 · cplusplus/draft