https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636
Adam Butcher <abutcher at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|adam at jessamine dot co.uk |abutcher at gcc dot gnu.org --- Comment #4 from Adam Butcher <abutcher at gcc dot gnu.org> --- (In reply to tower120 from comment #0) > > std::cout << if_else(do_first, data, > [&](auto /*B&*/ data){ > std::cout << std::endl; > std::cout << std::is_same<decltype(data), B>::value; > std::cout << std::endl; > > return fn1(/*static_cast<B&>*/(data)); > }, > [&](A& data){ return fn2(data); } > ); > } > }; > This works if "this->" is used to explicitly specify the object upon which to call 'fn1'. It works whether or not the static_cast is present or whether auto or B is is used. It looks like a binding issue with lambda templates; the name 'fn1' is being seen as a reference to the member function rather than an attempt to bind it to the captured 'this' for a member call. The fact that clang compiles it fine makes me think that this is indeed a genuine bug and that the extra "this->" qualification is not required by the language. In dependent base member access, an explicit "this->" is required, but I don't think it should be necessary here. I'll have a look into it; but I've limited time to do so at the mo.