[clang] [Clang] CWG2749: relational operators involving pointers to void (PR #93046)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 13:43:46 PDT 2024


================
@@ -18,6 +30,38 @@ void f(B b) {
 struct D : B {};
 } // namespace cwg2718
 
+namespace cwg2749 { // cwg2749: 19
+
+extern int x[2];
+struct Y {
+  int i;
+  int j;
+};
+extern Y y[2];
+
+#if __cplusplus >= 201103L
+static_assert(static_cast<void*>(x + 0) < static_cast<void*>(x + 1), "");
+static_assert(static_cast<void*>(&y[0].i) < static_cast<void*>(&y[0].j), "");
+static_assert(static_cast<void*>(&y[0].j) < static_cast<void*>(&y[1].i), "");
+#else
+enum X {
+  a = static_cast<void*>(x + 0) < static_cast<void*>(x + 1),
----------------
Endilll wrote:

Feel free to remove the test in C++98 if it doesn't fit the requirements of integral constant expression, but for the future reference we also use the following in some DR tests: https://github.com/llvm/llvm-project/blob/0eb9e021b15f477b796a6aaed94c94887f19171c/clang/test/CXX/drs/cwg1xx.cpp#L13-L17

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


More information about the cfe-commits mailing list