[Bug c++/101566] gcc miscompiles lambda used as tuple-like object applied to function for call
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 21 19:56:55 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101566
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Dale Weiler from comment #5)
> This is curious, omitting `decltype(auto)` for get, as in just `auto` seems
> to work around the issue as well.
>
> template<Size N, typename T>
> constexpr auto get(T tuple) { return *tuple(Get<N>{}); }
>
> I'm a bit out of my element here, in that I don't understand the semantic
> differences between the two and if that behavior is correct.
auto makes it return by value, decltype(auto) returns exactly the type of the
return statement (so if it's a reference, so is the return type).
More information about the Gcc-bugs
mailing list