This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1913. decltype((x)) in lambda-expressions

Section: 7.5.5  [expr.prim.lambda]     Status: CD5     Submitter: Dinka Ranns     Date: 2014-04-15

[Accepted as a DR as part of paper P0588R1 at the October, 2017 meeting.]

According to 7.5.5 [expr.prim.lambda] paragraph 19,

Every occurrence of decltype((x)) where x is a possibly parenthesized id-expression that names an entity of automatic storage duration is treated as if x were transformed into an access to a corresponding data member of the closure type that would have been declared if x were an odr-use of the denoted entity.

This formulation is problematic because it assumes that x can be captured and, if captured, would result in a member of the closure class. The former is not true if the lambda has no capture-default, and the latter is not guaranteed if the capture-default is &.