Skip to content
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

[libc++][format] LWG4106: basic_format_args should not be default-constructible #97250

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

frederick-vs-ja
Copy link
Contributor

See LWG4106 and P3341R0.

The test coverage for the empty state of basic_format_args in get.pass.cpp is to be completely removed, because the non-default-constructibility is covered in ctor.pass.cpp.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner July 1, 2024 02:22
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2024

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

Changes

See LWG4106 and P3341R0.

The test coverage for the empty state of basic_format_args in get.pass.cpp is to be completely removed, because the non-default-constructibility is covered in ctor.pass.cpp.


Full diff: https://github.com/llvm/llvm-project/pull/97250.diff

3 Files Affected:

  • (modified) libcxx/include/__format/format_args.h (-2)
  • (modified) libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp (+2-7)
  • (modified) libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp (-5)
diff --git a/libcxx/include/__format/format_args.h b/libcxx/include/__format/format_args.h
index a5fde36a29817..07923570f3893 100644
--- a/libcxx/include/__format/format_args.h
+++ b/libcxx/include/__format/format_args.h
@@ -28,8 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Context>
 class _LIBCPP_TEMPLATE_VIS basic_format_args {
 public:
-  basic_format_args() noexcept = default;
-
   template <class... _Args>
   _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
       : __size_(sizeof...(_Args)) {
diff --git a/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp
index c0575c545bde3..bb542a8e63ecf 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp
@@ -9,12 +9,12 @@
 
 // <format>
 
-// basic_format_args() noexcept;
 // template<class... Args>
 //   basic_format_args(const format-arg-store<Context, Args...>& store) noexcept;
 
 #include <format>
 #include <cassert>
+#include <type_traits>
 
 #include "test_macros.h"
 
@@ -24,12 +24,7 @@ void test() {
   char c        = 'c';
   nullptr_t p   = nullptr;
   using Context = std::basic_format_context<CharT*, CharT>;
-  {
-    ASSERT_NOEXCEPT(std::basic_format_args<Context>{});
-
-    std::basic_format_args<Context> format_args{};
-    assert(!format_args.get(0));
-  }
+  static_assert(!std::is_default_constructible_v<std::basic_format_args<Context>>);
   {
     auto store = std::make_format_args<Context>(i);
     ASSERT_NOEXCEPT(std::basic_format_args<Context>{store});
diff --git a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
index c590cebf48acc..af8d7eff6f6b8 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
@@ -82,11 +82,6 @@ void test_string_view(From value) {
 template <class CharT>
 void test() {
   using Context = std::basic_format_context<CharT*, CharT>;
-  {
-    const std::basic_format_args<Context> format_args{};
-    ASSERT_NOEXCEPT(format_args.get(0));
-    assert(!format_args.get(0));
-  }
 
   using char_type = typename Context::char_type;
   std::basic_string<char_type> empty;

@mordante mordante self-assigned this Jul 4, 2024
Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM modulo one nit.

(I'll make sure this is updated on the status page once we updated it for St. Louis.)

Copy link

github-actions bot commented Jul 5, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@mordante
Copy link
Member

mordante commented Jul 8, 2024

I've just committed #97951 can you rebase your patch on main and update the status page for this patch.

@frederick-vs-ja
Copy link
Contributor Author

I've just committed #97951 can you rebase your patch on main and update the status page for this patch.

Done.

@mordante mordante merged commit 96c9913 into llvm:main Jul 9, 2024
55 checks passed
@frederick-vs-ja frederick-vs-ja deleted the lwg-4106 branch July 9, 2024 10:29
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
…onstructible (llvm#97250)

See [LWG4106](https://cplusplus.github.io/LWG/issue4106) and
[P3341R0](https://wg21.link/p3341r0).

The test coverage for the empty state of `basic_format_args` in
`get.pass.cpp` is to be completely removed, because the
non-default-constructibility is covered in `ctor.pass.cpp`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants