[PATCH] Fix return type detection in <variant> visit()

Tim Shen via gcc-patches gcc-patches@gcc.gnu.org
Wed Feb 15 08:15:00 GMT 2017


On Tue, Feb 14, 2017 at 2:49 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> 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);

Even better, I used the shiny new [[gnu::unused]]. :)

>
> OK for trunk if testing passes, thanks.
>

Tested and committed.


-- 
Regards,
Tim Shen



More information about the Gcc-patches mailing list