-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Let's look a the following code
int main()
{
int x = 1, y = 2;
auto f = [&](auto self) {
(void)x; (void)y; // make 'em used!
auto& [a, b] = *self; // a == 1, b == 2. Depends on the previous line.
return b - a;
};
return f(&f); // returns 1
}it is transformed into
int main()
{
int x = 1;
int y = 2;
class __lambda_4_11
{
int & x;
int & y;
public: inline /*constexpr */ int operator()(__lambda_4_11 * self) const
{
static_cast<void>(x);
static_cast<void>(y);
__lambda_4_11 & __self6 = *self;
int && a = __self6.;
int && b = __self6.;
return b - a;
}
public: __lambda_4_11(int & _x, int & _y)
: x{_x}
, y{_y}
{}
};
__lambda_4_11 f = __lambda_4_11{x, y};
return f.operator()(&f);
}In the lines 15 and 16:
int && a = __self6.;
int && b = __self6.;data member names are missing. Also, I believe, the types of a and b should be int&, not int&&:
int & a = __self6.x;
int & b = __self6.y;Not fixing this is also an option, because it is believed that closure object decomposition should be banned by the Standard.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working