PR libstdc++/84532 prevent unwrapping of reference_wrapper arguments
PR libstdc++/84532 * include/std/thread (thread::__make_invoker): Construct tuple directly instead of using make_tuple. * testsuite/30_threads/async/84532.cc: New. * testsuite/30_threads/thread/84532.cc: New. From-SVN: r257956
This commit is contained in:
parent
8af2826bb0
commit
cc53514672
@ -1,3 +1,11 @@
|
||||
2018-02-23 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/84532
|
||||
* include/std/thread (thread::__make_invoker): Construct tuple
|
||||
directly instead of using make_tuple.
|
||||
* testsuite/30_threads/async/84532.cc: New.
|
||||
* testsuite/30_threads/thread/84532.cc: New.
|
||||
|
||||
2018-02-20 François Dumont <fdumont@gcc.gnu.org>
|
||||
|
||||
* include/ext/aligned_buffer.h [_GLIBCXX_INLINE_VERSION]
|
||||
|
@ -243,21 +243,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
{ return _M_invoke(_Indices()); }
|
||||
};
|
||||
|
||||
// Alias for _Invoker<tuple<DECAY_COPY(_Tp)...>>
|
||||
template<typename... _Tp>
|
||||
using __invoker_type
|
||||
= _Invoker<decltype(std::make_tuple(std::declval<_Tp>()...))>;
|
||||
using __decayed_tuple = tuple<typename std::decay<_Tp>::type...>;
|
||||
|
||||
public:
|
||||
// Returns a call wrapper that does
|
||||
// INVOKE(DECAY_COPY(__callable), DECAY_COPY(__args)).
|
||||
// Returns a call wrapper that stores
|
||||
// tuple{DECAY_COPY(__callable), DECAY_COPY(__args)...}.
|
||||
template<typename _Callable, typename... _Args>
|
||||
static __invoker_type<_Callable, _Args...>
|
||||
static _Invoker<__decayed_tuple<_Callable, _Args...>>
|
||||
__make_invoker(_Callable&& __callable, _Args&&... __args)
|
||||
{
|
||||
return { {
|
||||
std::make_tuple(std::forward<_Callable>(__callable),
|
||||
std::forward<_Args>(__args)...)
|
||||
return { __decayed_tuple<_Callable, _Args...>{
|
||||
std::forward<_Callable>(__callable), std::forward<_Args>(__args)...
|
||||
} };
|
||||
}
|
||||
};
|
||||
|
38
libstdc++-v3/testsuite/30_threads/async/84532.cc
Normal file
38
libstdc++-v3/testsuite/30_threads/async/84532.cc
Normal file
@ -0,0 +1,38 @@
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-require-gthreads "" }
|
||||
|
||||
// Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <future>
|
||||
|
||||
// PR libstdc++/84532
|
||||
|
||||
struct F
|
||||
{
|
||||
template<typename T, typename U>
|
||||
void operator()(T, U, int&)
|
||||
{
|
||||
using std::is_same;
|
||||
using std::reference_wrapper;
|
||||
static_assert(is_same<T, reference_wrapper<int>>::value, "");
|
||||
static_assert(is_same<U, reference_wrapper<const int>>::value, "");
|
||||
}
|
||||
};
|
||||
int i = 0;
|
||||
auto fut = std::async(F{}, std::ref(i), std::cref(i), std::ref(i));
|
38
libstdc++-v3/testsuite/30_threads/thread/84532.cc
Normal file
38
libstdc++-v3/testsuite/30_threads/thread/84532.cc
Normal file
@ -0,0 +1,38 @@
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-require-gthreads "" }
|
||||
|
||||
// Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <thread>
|
||||
|
||||
// PR libstdc++/84532
|
||||
|
||||
struct F
|
||||
{
|
||||
template<typename T, typename U>
|
||||
void operator()(T, U, int&)
|
||||
{
|
||||
using std::is_same;
|
||||
using std::reference_wrapper;
|
||||
static_assert(is_same<T, reference_wrapper<int>>::value, "");
|
||||
static_assert(is_same<U, reference_wrapper<const int>>::value, "");
|
||||
}
|
||||
};
|
||||
int i = 0;
|
||||
std::thread t(F{}, std::ref(i), std::cref(i), std::ref(i));
|
Loading…
Reference in New Issue
Block a user