[llvm-branch-commits] [libcxx] Prepare libcxx and libcxxabi for pointer field protection. (PR #151651)

Peter Collingbourne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 5 16:21:58 PST 2025


================
@@ -34,10 +34,13 @@ template <class _Tp, class = void>
 struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {};
 #endif
 
+// __trivially_relocatable on libc++'s builtin types does not currently return the right answer with PFP.
----------------
pcc wrote:

The property is that the type must satisfy both of the following:
- contains a field of pointer type, either in the type itself or in one of its fields or bases
- the type containing the pointer field is not trivially copyable

Given that many of the affected types are containers, the trivial relocatability property will in some cases depend on a template argument. In other cases, the type is unconditionally non-trivially relocatable due to a pointer field.

In principle, we would be able to robustly detect this property via a type trait, and in an earlier version of the Clang patch I introduced such a trait: https://github.com/pcc/llvm-project/commit/ad5ee79d12f775c8d2478349ce4ae593d9f687be

But in #133538 @ojhunt reasonably asked for this to be removed for the initial version of the patch. We can revisit this as an optimization once trivial relocatability is added to the standard. Given that trivial relocatability will not be making it into C++26, I think this should not be a priority for now.

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


More information about the llvm-branch-commits mailing list