[libcxx-commits] [libcxx] [libc++] Test LWG4113: Disallow `has_unique_object_representations<Incomplete[]>` (PR #169446)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 11 05:51:42 PDT 2026


================
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++17
+
+// <type_traits>
+
+// has_unique_object_representations
+
+// Verify that has_unique_object_representations(_v) rejects incomplete class and enumeration types and arrays thereof.
+
+#include <type_traits>
+
+class IC;
+
+constexpr bool v1 = std::has_unique_object_representations<IC>::value;
+constexpr bool v2 = std::has_unique_object_representations<IC[]>::value;
+constexpr bool v3 = std::has_unique_object_representations<IC[1]>::value;
+constexpr bool v4 = std::has_unique_object_representations<IC[][1]>::value;
+
+constexpr bool v5 = std::has_unique_object_representations_v<IC>;
+constexpr bool v6 = std::has_unique_object_representations_v<IC[]>;
+constexpr bool v7 = std::has_unique_object_representations_v<IC[1]>;
+constexpr bool v8 = std::has_unique_object_representations_v<IC[][1]>;
+
+// expected-error@*:* 8 {{incomplete type 'IC' used in type trait expression}}
----------------
frederick-vs-ja wrote:

Hmm, we can't do so. Clang's `__has_unique_object_representations` causes hard error now. https://godbolt.org/z/M77EW4rGv

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


More information about the libcxx-commits mailing list