[libcxx-commits] [libcxx] [libc++] Add static_assert diagnostics for LWG3133 named requirements (PR #212360)

Yordan Vásquez via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 4 23:16:30 PDT 2026


================
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// XFAIL: FROZEN-CXX03-HEADERS-FIXME
+
+// <valarray>
+
+// template<class T>
+// class valarray
+//
+// T shall be a cv-unqualified object type that satisfies the Cpp17DefaultConstructible,
+// Cpp17CopyConstructible, Cpp17CopyAssignable, and Cpp17Destructible requirements (LWG3133)
+
+#include <valarray>
+
+struct NotDefaultConstructible {
+  NotDefaultConstructible() = delete;
+};
+
+struct NotCopyConstructible {
+  NotCopyConstructible()                            = default;
+  NotCopyConstructible(const NotCopyConstructible&) = delete;
+};
+
+struct NotCopyAssignable {
+  NotCopyAssignable()                                    = default;
+  NotCopyAssignable(const NotCopyAssignable&)            = default;
+  NotCopyAssignable& operator=(const NotCopyAssignable&) = delete;
+};
+
+struct NotDestructible {
+  NotDestructible()                                  = default;
+  NotDestructible(const NotDestructible&)            = default;
+  NotDestructible& operator=(const NotDestructible&) = default;
+
+private:
+  ~NotDestructible() = default;
+};
+
+void test() {
+  // expected-error-re at valarray:* {{static assertion failed{{.*}}std::valarray<T> requires T to be a cv-unqualified object type}}
----------------
vyordan wrote:

@H-G-Hristov 

I like the idea of a tighter check than the `*` wildcard, but I ran into a compile failure trying `@+1` locally: the static_assert diagnostic is reported by Clang at its declaration site inside <valarray> (the header, not the call site here), so `-verify` doesn't find it at `@+1` and the test fails to build.

Reverted back to `@valarray:*` for now, since that's what actually passes. If you'd still like something more specific than the wildcard, I could pin it to the exact line number in the header instead (e.g. `@valarray:794`), though that adds a small maintenance cost if the header shifts around it later. Happy to go either way.

https://github.com/llvm/llvm-project/pull/212360


More information about the libcxx-commits mailing list