[PATCH] Fix return type detection in <variant> visit()
Jonathan Wakely
jwakely@redhat.com
Wed Feb 15 06:54:00 GMT 2017
On 14/02/17 13:59 -0800, Tim Shen via libstdc++ wrote:
>This is an obvious missing std::forward. :)
I was about to look into it, I assumed it would be something simple!
>diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc
>index 65f4326c397..d40a4ccb784 100644
>--- a/libstdc++-v3/testsuite/20_util/variant/compile.cc
>+++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc
>@@ -291,6 +291,13 @@ void test_visit()
> };
> static_assert(visit(Visitor(), variant<int, nonliteral>(0)), "");
> }
>+ // PR libstdc++/79513
>+ {
>+ std::variant<int> v(5);
>+ std::visit([](int&){}, v);
>+ std::visit([](int&&){}, std::move(v));
>+ (void)v;
Is this to suppress an unused variable warning?
If it is, please use an attribute instead, as it's more reliable:
std::variant<int> v __attribute__((unused)) (5);
OK for trunk if testing passes, thanks.
More information about the Gcc-patches
mailing list