[libcxx-commits] [libcxx] [libc++] Add static_assert diagnostics for LWG3133 named requirements (PR #212360)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 5 05:08:13 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}}
----------------
philnik777 wrote:
This should be `*.*`, since we don't care where exactly the diagnostic is emitted, and specifying the header just causes maintenance burden without any benefit.
Diagnosing at the point of instantiation would be nice, but we don't have that option currently.
https://github.com/llvm/llvm-project/pull/212360
More information about the libcxx-commits
mailing list