This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


958. Lambdas and decltype

Section: 7.5.5  [expr.prim.lambda]     Status: NAD     Submitter: Jason Merrill     Date: 31 August, 2009

The following case is ill-formed:

    int f (int&);
    void* f (const int&);

    int main()
       int i;
       [=] ()-> decltype(f(i)) { return f(i); };

The decltype(f(i)) is not of the form decltype((x)), and also not within the body of the lambda, so the special rewriting rule doesn't apply. So, the call in the decltype selects the first overload, and the call in the body selects the second overload, and there's no conversion from void* to int, so the return-statement is ill-formed.

This pattern is likely to arise frequently because of the retrictions on deducing the return type from the body of the lambda.

Daveed Vandevoorde: The pattern may be common, but it probably doesn't matter much in practice. It's most likely that overloaded functions that differ only in the cv-qualification of their parameters will have related return types.

Rationale (October, 2009):

The consensus of the CWG was that this is not a sufficiently important problem to warrant changing the existing specification.