[gcc r17-2308] libstdc++: Test has_unique_object_representations with incomplete types.

Tomasz Kaminski via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <20260710133216.D78F34BA2E07__39004.1135063925$1783690346$gmane$org@sourceware.org>
https://gcc.gnu.org/g:ce964ffb653f7134f93b662a332a9467677066ac

commit r17-2308-gce964ffb653f7134f93b662a332a9467677066ac
Author: Tomasz Kamiński <[email protected]>
Date:   Fri Jul 10 15:02:13 2026 +0200

    libstdc++: Test has_unique_object_representations with incomplete types.
    
    Covers LWG4113, "Disallow has_unique_object_representations<Incomplete[]>".
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/20_util/has_unique_object_representations/neg.cc:
            New test.

Diff:
---
 .../20_util/has_unique_object_representations/neg.cc      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc b/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc
new file mode 100644
index 000000000000..9654fb4b99ad
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++17 } }
+
+#include <type_traits>
+
+struct Incomplete;
+
+static_assert(std::has_unique_object_representations_v<Incomplete>);       // { dg-error "here" }
+static_assert(std::has_unique_object_representations_v<const Incomplete>); // { dg-error "here" }
+static_assert(std::has_unique_object_representations_v<Incomplete[10]>);   // { dg-error "here" }
+static_assert(std::has_unique_object_representations_v<Incomplete[]>);     // { dg-error "here" }
+
+// { dg-prune-output "invalid use of incomplete type" }
+// { dg-prune-output "template argument must be a complete" }
+// { dg-prune-output "'value' is not a member of 'std::has_unique_object_representations" }
+// { dg-prune-output "static assertion" }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.