llvm-project
30084d74 - [libc++] Fix type confusion in hash_{,multi}map

Commit
2 days ago
[libc++] Fix type confusion in hash_{,multi}map 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. Reviewers: ldionne Reviewed By: ldionne Pull Request: https://github.com/llvm/llvm-project/pull/183223
Author
pcc pcc
Parents
Loading