Skip to content

Commit 30cc1b6

Browse files
committed
libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args
This is LWG 3220 which is about to become Tentatively Ready. libstdc++-v3/ChangeLog: * include/std/atomic (__atomic_val_t): Use __type_identity_t instead of atomic<T>::value_type, as per LWG 3220. * testsuite/29_atomics/atomic/lwg3220.cc: New test.
1 parent b3dd7d8 commit 30cc1b6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

libstdc++-v3/include/std/atomic

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
12441244
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
12451245

12461246
/// @cond undocumented
1247+
// _GLIBCXX_RESOLVE_LIB_DEFECTS
1248+
// 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
12471249
template<typename _Tp>
1248-
using __atomic_val_t = typename atomic<_Tp>::value_type;
1250+
using __atomic_val_t = __type_identity_t<_Tp>;
12491251
template<typename _Tp>
12501252
using __atomic_diff_t = typename atomic<_Tp>::difference_type;
12511253
/// @endcond
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// { dg-do compile { target c++11 } }
2+
// DR 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
3+
4+
#include <atomic>
5+
#include <memory>
6+
7+
struct Abstract { virtual void test() = 0; };
8+
struct Concrete : Abstract { virtual void test() override {} };
9+
10+
int main() {
11+
std::shared_ptr<Abstract> ptr;
12+
std::atomic_store<Abstract>(&ptr, std::make_shared<Concrete>());
13+
}

0 commit comments

Comments
 (0)