Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[libc++] LWG4169: std::atomic<T>'s default constructor should be constrained #131950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 libcxx/docs/Status/Cxx2cIssues.csv
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"`LWG4154 <https://wg21.link/LWG4154>`__","The Mandates for ``std::packaged_task``'s constructor from a callable entity should consider decaying","2024-11 (Wrocław)","","",""
"`LWG4157 <https://wg21.link/LWG4157>`__","The resolution of LWG3465 was damaged by P2167R3","2024-11 (Wrocław)","","20",""
"`LWG4164 <https://wg21.link/LWG4164>`__","Missing guarantees for ``forward_list`` modifiers","2024-11 (Wrocław)","","",""
"`LWG4169 <https://wg21.link/LWG4169>`__","``std::atomic<T>``'s default constructor should be constrained","2024-11 (Wrocław)","","",""
"`LWG4169 <https://wg21.link/LWG4169>`__","``std::atomic<T>``'s default constructor should be constrained","2024-11 (Wrocław)","|Complete|","21",""
"`LWG4170 <https://wg21.link/LWG4170>`__","``contiguous_iterator`` should require ``to_address(I{})``","2024-11 (Wrocław)","","",""
"","","","","",""
"`LWG3578 <https://wg21.link/3578>`__","Iterator SCARYness in the context of associative container merging","2025-02 (Hagenberg)","","",""
Expand Down
5 changes: 4 additions & 1 deletion 5 libcxx/include/__atomic/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <__cstddef/ptrdiff_t.h>
#include <__memory/addressof.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_floating_point.h>
#include <__type_traits/is_function.h>
#include <__type_traits/is_integral.h>
Expand Down Expand Up @@ -235,7 +236,9 @@ struct atomic : public __atomic_base<_Tp> {
using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;

#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI atomic() = default;
_LIBCPP_HIDE_FROM_ABI atomic()
requires is_default_constructible_v<_Tp>
= default;
#else
_LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;
#endif
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// Test the properties of std::atomic's default constructor.

#include <atomic>
#include <type_traits>

#include "test_macros.h"

template <typename T>
void test() {
#if TEST_STD_VER >= 11
constexpr T a{};
(void)a;
# if TEST_STD_VER >= 20
[[maybe_unused]] constexpr T b;
# endif
#else
T a;
(void)a;
#endif
static_assert(std::is_nothrow_constructible<T>::value, "");
ASSERT_NOEXCEPT(T{});
}

struct throwing {
throwing() {}
};

struct trivial {
int a;
};

struct not_default_constructible {
explicit not_default_constructible(int) {}
};

void test() {
test<std::atomic<bool> >();
test<std::atomic<int> >();
test<std::atomic<int*> >();
test<std::atomic<trivial> >();
test<std::atomic_flag>();

#if TEST_STD_VER >= 20
static_assert(!std::is_nothrow_constructible_v<std::atomic<throwing>>);
ASSERT_NOT_NOEXCEPT(std::atomic<throwing>{});

static_assert(!std::is_default_constructible_v<std::atomic<not_default_constructible>>);
#else
static_assert(std::is_nothrow_constructible<std::atomic<throwing> >::value, "");

ASSERT_NOEXCEPT(std::atomic<throwing>{});
# ifndef TEST_COMPILER_GCC
static_assert(std::is_default_constructible<std::atomic<not_default_constructible> >::value, "");
# endif
#endif
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.