[clang] [clang] Implement CWG1719 "Layout compatibility and cv-qualification revisited" (PR #82358)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 11:00:44 PST 2024


================
@@ -66,11 +66,10 @@ struct CStructWithQualifiers {
 static_assert(__is_layout_compatible(CStruct, const CStruct2), "");
 static_assert(__is_layout_compatible(CStruct, volatile CStruct2), "");
 static_assert(__is_layout_compatible(const CStruct, volatile CStruct2), "");
-// FIXME: all of the following pairs of types are layout-compatible
-static_assert(!__is_layout_compatible(int, const int), "");
-static_assert(!__is_layout_compatible(int, volatile int), "");
-static_assert(!__is_layout_compatible(const int, volatile int), "");
-static_assert(!__is_layout_compatible(CStruct, CStructWithQualifiers), "");
+static_assert(__is_layout_compatible(int, const int), "");
+static_assert(__is_layout_compatible(int, volatile int), "");
+static_assert(__is_layout_compatible(const int, volatile int), "");
----------------
AaronBallman wrote:

Another test case for us to consider is:
```
static_assert(__is_layout_compatible(int *, int * __restrict), "");
// Note: atomic qualification matters for layout compatibility.
static_assert(!__is_layout_compatible(int, _Atomic int), "");
static_assert(__is_layout_compatible(_Atomic(int), _Atomic int), "");
```


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


More information about the cfe-commits mailing list