https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83406
Bug ID: 83406
Summary: GCC8 can't deduce lambda return type
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ostash at ostash dot kiev.ua
Target Milestone: ---
Following code:
-----
class Foo{};
class Bar
{
public:
const Foo& getFoo() const;
Foo& getFoo();
};
auto getter = [](const Bar& bar) -> decltype(auto) { return bar.getFoo(); };
-----
is reject with GCC8 trunk with:
error: inconsistent types 'Foo' and 'const Foo&' deduced for lambda return type
auto getter = [](const Bar& bar) -> decltype(auto) { return bar.getFoo(); };
^
GCC6, GCC7 and Clang are ok with it in both C++14/C++17 modes.