This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix return type detection in <variant> visit()
- From: "Tim Shen via gcc-patches" <gcc-patches at gcc dot gnu dot org>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 14 Feb 2017 23:43:28 -0800
- Subject: Re: [PATCH] Fix return type detection in <variant> visit()
- Authentication-results: sourceware.org; auth=none
- References: <CAG4ZjNkSk3z9Mg5-kTD=su+gRCJihwAQwD=NFDfN20Lg_BgM0Q@mail.gmail.com> <20170214224938.GA4602@redhat.com>
- Reply-to: Tim Shen <timshen at google dot com>
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