[libcxx-commits] [libcxx] [libc++] Fix type confusion in hash_{, multi}map (PR #183223)
Oliver Hunt via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 24 17:49:47 PST 2026
ojhunt wrote:
> The type __gnu_cxx::hash_{,multi}map creates objects of type `std::pair<Key, Value>` and returns pointers to them of type `std::pair<const Key, Value>`. If either `Key` or `Value` are non-standard-layout, this is UB, and is furthermore considered by pointer field protection to be a type confusion, which leads to a program crash. Fix it by using the correct type for the pair's storage and using const_cast to form a pointer to the key in the one place where that is needed.
This seems like an over-strictness of pfp, but what is the non-standard layout case where this is ub? basically I'm trying to determine whether this creates an abi issue (this is simply because I have a generalized paranoia about changes related to non-standard layout types)
https://github.com/llvm/llvm-project/pull/183223
More information about the libcxx-commits
mailing list