From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30053 invoked by alias); 7 Jul 2014 07:08:01 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29702 invoked by uid 48); 7 Jul 2014 07:07:37 -0000 From: "abutcher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61636] generic lambda "cannot call member function without object" Date: Mon, 07 Jul 2014 07:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: abutcher at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: abutcher at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00329.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636 --- Comment #8 from Adam Butcher --- (In reply to tower120 from comment #7) > I'm not sure what you mean, about adding "this->". > I meant spelling "fn1(data)" as "this->fn1(data)" to explicitly specify the subject of the member call. > But this case is not working : > http://coliru.stacked-crooked.com/a/d69de477f9a746cb > > But to be true, it not work with clang either. > In the case you link to, specifically within the member function template 'go', std::cout << if_else( [&]{ return this->fn1(data); }, [&]{ return this->fn2(data); } ) << '\n'; you are building up two non-generic (non-template) lambdas that are not dependent on any template parameter. The if_else is, but the two arguments are not. Both have to be evaluated to pass to the if_else. Because they are not templates, the body of both lambdas must be well formed within 'go'. 'fn1' and 'fn2' are both being passed 'data' which is either of type 'A' or of type 'B'. There are no overloads of 'fn1' that can accept a 'B'. That's what both clang and g++ are getting at in their diagnostics. The fact that g++ proceeds to ICE on recovery is another issue.