[libcxx-commits] [libcxx] [libc++] Take the ABI break for `std::list`'s pointer UB unconditionally (PR #100585)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 15 08:55:36 PDT 2024
================
@@ -271,19 +271,10 @@ struct __list_node_pointer_traits {
typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer;
typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer;
-#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
----------------
ldionne wrote:
For LLVM 20, we could add this to guard against unintended ABI breaks:
```c++
#if !defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
// TODO: Remove this diagnostic in LLVM 22.
static_assert(sizeof(__base_pointer) == sizeof(__node_pointer) && alignof(...) == alignof(...),
"It looks like you are using std::list with a fancy pointer type that has a different representation depending on
whether it points to a list base pointer vs a list node pointer (both of which are implementation details of the Standard Library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
#endif
```
The goal here is to catch unintended ABI breaks at compile-time. However, if you were already using `_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB`, then you don't care about any of this and we shouldn't produce a diagnostic just because your fancy pointer type has a different representation.
We then remove the diagnostic in LLVM 22 if we haven't encountered any issues. I think it's very likely that this will never cause issues, but we're better off being careful.
https://github.com/llvm/llvm-project/pull/100585
More information about the libcxx-commits
mailing list