Bug 46048 - lambda: access to a member function
Summary: lambda: access to a member function
Status: RESOLVED DUPLICATE of bug 46047
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-16 15:00 UTC by Mikhail Semenov
Modified: 2010-10-16 15:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Semenov 2010-10-16 15:00:50 UTC
In GCC 4.5.0 the follwing class fails to compile. In C++0x draft n3126, the member variable 'f' does not require 'this->'. Surely the same should apply to a member function.

struct S10 
{
	int f;
	double p;
        void inc(int& a) { a += f;}
	void work(int n) 
	{
		int m = n*n;
		int j = 40;
		f = 10;
		p =3.7;
		auto m3 = [this,&n]() mutable -> int
		{
			p++;
			f++;       
                        this->inc(n); //required                
			return n;
		};
		cout << "S9 m3():" << m3() << endl;
		cout << "f:" << f << " p:" << p << " n:" << n << endl;
	}
};
Comment 1 Mikhail Semenov 2010-10-16 15:03:36 UTC
The code fails to compile is "this->inc(n);" is replaced with "inc(n);"
Comment 2 Jonathan Wakely 2010-10-16 15:26:28 UTC
dup

*** This bug has been marked as a duplicate of bug 46047 ***