This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61636] generic lambda "cannot call member function without object"
- From: "abutcher at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 Jul 2014 07:07:23 +0000
- Subject: [Bug c++/61636] generic lambda "cannot call member function without object"
- Auto-submitted: auto-generated
- References: <bug-61636-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636
--- Comment #8 from Adam Butcher <abutcher at gcc dot gnu.org> ---
(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<do_it>(
[&]{ 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.