libstdc++: Value-initialize std::atomic for C++20 (P0883R2)
authorJonathan Wakely <jwakely@redhat.com>
Sat, 11 Jan 2020 00:11:54 +0000 (00:11 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 13 Jan 2020 13:22:28 +0000 (13:22 +0000)
commite4379a931d140a71b36eaecceace319837fda321
tree014062564f8ba50a3b362f59878320caaea76b38
parentaef85e40e0c5e242f1a1883abc56159dcd90e7b0
libstdc++: Value-initialize std::atomic for C++20 (P0883R2)

This implements the new requirements for C++20 that std::atomic should
initialize the atomic variable in its default constructor.

This patch does not add the deprecated attribute to atomic_init, but
that should be done at some point as it's deprecated in C++20.

The paper also deprecates the ATOMIC_FLAG_INIT macro, although we can't
apply the deprecated attribute to a macro.

PR libstdc++/58605
* include/bits/atomic_base.h (__cpp_lib_atomic_value_initialization):
Define.
(__atomic_flag_base, __atomic_base, __atomic_base<_PTp*>)
(__atomic_float): Add default member initializer for C++20.
* include/std/atomic (atomic): Likewise.
(atomic::atomic()): Remove noexcept-specifier on default constructor.
* include/std/version (__cpp_lib_atomic_value_initialization): Define.
* testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust dg-error line
number.
* testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise.
* testsuite/29_atomics/atomic/cons/value_init.cc: New test.
* testsuite/29_atomics/atomic_flag/cons/value_init.cc: New test.
* testsuite/29_atomics/atomic_flag/requirements/trivial.cc: Adjust
expected result for is_trivially_default_constructible.
* testsuite/29_atomics/atomic_float/requirements.cc: Likewise.
* testsuite/29_atomics/atomic_float/value_init.cc: New test.
* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Likewise.
* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
* testsuite/29_atomics/atomic_integral/cons/value_init.cc
* testsuite/29_atomics/atomic_integral/requirements/trivial.cc: Adjust
expected results for is_trivially_default_constructible.
* testsuite/util/testsuite_common_types.h (has_trivial_dtor): Add
new test generator.
16 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/atomic_base.h
libstdc++-v3/include/std/atomic
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
libstdc++-v3/testsuite/29_atomics/atomic/cons/value_init.cc [new file with mode: 0644]
libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/value_init.cc [new file with mode: 0644]
libstdc++-v3/testsuite/29_atomics/atomic_flag/requirements/trivial.cc
libstdc++-v3/testsuite/29_atomics/atomic_float/requirements.cc
libstdc++-v3/testsuite/29_atomics/atomic_float/value_init.cc [new file with mode: 0644]
libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/value_init.cc [new file with mode: 0644]
libstdc++-v3/testsuite/29_atomics/atomic_integral/requirements/trivial.cc
libstdc++-v3/testsuite/util/testsuite_common_types.h