[libcxx-commits] [libcxx] [libc++] Verify that LWG4140 is implemented (PR #128624)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 1 11:00:10 PST 2025
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/128624
>From 2e2aeb3ceb2df8d443afe1020fe98e62b3bcc9a5 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 25 Feb 2025 12:20:01 +0800
Subject: [PATCH 1/2] [libc++] Verify that LWG4140 is implemented
According to the commit history, the constructors removed by LWG4140
have never been added to libc++.
Existence of non-public or deleted default constructor is observable,
this patch tests that there're no such default constructor at all.
---
libcxx/docs/Status/Cxx2cIssues.csv | 2 +-
.../ctor_no_default.compile.pass.cpp | 26 ++++++++++++
...reference.ctor_no_default.compile.pass.cpp | 41 +++++++++++++++++++
3 files changed, 68 insertions(+), 1 deletion(-)
create mode 100644 libcxx/test/std/containers/sequences/vector.bool/reference/ctor_no_default.compile.pass.cpp
create mode 100644 libcxx/test/std/utilities/template.bitset/bitset.members/reference.ctor_no_default.compile.pass.cpp
diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index 1ec23dfabd5ea..731cee8df2cf3 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -98,7 +98,7 @@
"`LWG4126 <https://wg21.link/LWG4126>`__","Some feature-test macros for fully freestanding features are not yet marked freestanding","2024-11 (Wrocław)","","",""
"`LWG4134 <https://wg21.link/LWG4134>`__","Issue with Philox algorithm specification","2024-11 (Wrocław)","","",""
"`LWG4135 <https://wg21.link/LWG4135>`__","The helper lambda of ``std::erase`` for list should specify return type as ``bool``","2024-11 (Wrocław)","","",""
-"`LWG4140 <https://wg21.link/LWG4140>`__","Useless default constructors for bit reference types","2024-11 (Wrocław)","","",""
+"`LWG4140 <https://wg21.link/LWG4140>`__","Useless default constructors for bit reference types","2024-11 (Wrocław)","|Complete|","",""
"`LWG4141 <https://wg21.link/LWG4141>`__","Improve prohibitions on ""additional storage""","2024-11 (Wrocław)","","",""
"`LWG4142 <https://wg21.link/LWG4142>`__","``format_parse_context::check_dynamic_spec`` should require at least one type","2024-11 (Wrocław)","","",""
"`LWG4144 <https://wg21.link/LWG4144>`__","Disallow ``unique_ptr<T&, D>``","2024-11 (Wrocław)","","",""
diff --git a/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_no_default.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_no_default.compile.pass.cpp
new file mode 100644
index 0000000000000..a55caf28c8706
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_no_default.compile.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "test_macros.h"
+
+static_assert(!std::is_default_constructible<std::vector<bool>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::vector<bool, test_allocator<bool> >::reference>::value, "");
+
+#if TEST_STD_VER >= 11
+void test_no_ambiguity_among_default_constructors(std::enable_if<false>);
+void test_no_ambiguity_among_default_constructors(std::vector<bool>::reference);
+void test_no_ambiguity_among_default_constructors(std::vector<bool, test_allocator<bool>>::reference);
+
+ASSERT_SAME_TYPE(decltype(test_no_ambiguity_among_default_constructors({})), void);
+#endif
diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/reference.ctor_no_default.compile.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/reference.ctor_no_default.compile.pass.cpp
new file mode 100644
index 0000000000000..68d6380c09b50
--- /dev/null
+++ b/libcxx/test/std/utilities/template.bitset/bitset.members/reference.ctor_no_default.compile.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <bitset>
+
+#include <bitset>
+#include <type_traits>
+
+#include "test_macros.h"
+
+static_assert(!std::is_default_constructible<std::bitset<0>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<1>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<8>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<12>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<16>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<24>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<32>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<48>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<64>::reference>::value, "");
+static_assert(!std::is_default_constructible<std::bitset<96>::reference>::value, "");
+
+#if TEST_STD_VER >= 11
+void test_no_ambiguity_among_default_constructors(std::enable_if<false>);
+void test_no_ambiguity_among_default_constructors(std::bitset<0>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<1>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<8>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<12>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<16>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<24>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<32>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<48>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<64>::reference);
+void test_no_ambiguity_among_default_constructors(std::bitset<96>::reference);
+
+ASSERT_SAME_TYPE(decltype(test_no_ambiguity_among_default_constructors({})), void);
+#endif
>From b2db0959ea2300242e8f7486b5a61e6322a73295 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Sun, 2 Mar 2025 02:53:44 +0800
Subject: [PATCH 2/2] Change the status to Nothing To Do
---
libcxx/docs/Status/Cxx2cIssues.csv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index e245088fa0ab7..d9fe499ac16cb 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -98,7 +98,7 @@
"`LWG4126 <https://wg21.link/LWG4126>`__","Some feature-test macros for fully freestanding features are not yet marked freestanding","2024-11 (Wrocław)","","",""
"`LWG4134 <https://wg21.link/LWG4134>`__","Issue with Philox algorithm specification","2024-11 (Wrocław)","","",""
"`LWG4135 <https://wg21.link/LWG4135>`__","The helper lambda of ``std::erase`` for list should specify return type as ``bool``","2024-11 (Wrocław)","|Complete|","21",""
-"`LWG4140 <https://wg21.link/LWG4140>`__","Useless default constructors for bit reference types","2024-11 (Wrocław)","|Complete|","",""
+"`LWG4140 <https://wg21.link/LWG4140>`__","Useless default constructors for bit reference types","2024-11 (Wrocław)","|Nothing To Do|","",""
"`LWG4141 <https://wg21.link/LWG4141>`__","Improve prohibitions on ""additional storage""","2024-11 (Wrocław)","","",""
"`LWG4142 <https://wg21.link/LWG4142>`__","``format_parse_context::check_dynamic_spec`` should require at least one type","2024-11 (Wrocław)","","",""
"`LWG4144 <https://wg21.link/LWG4144>`__","Disallow ``unique_ptr<T&, D>``","2024-11 (Wrocław)","","",""
More information about the libcxx-commits
mailing list