[all-commits] [llvm/llvm-project] 979e93: [libc++] Fix improper static_cast in std::deque an...
Peng Liu via All-commits
all-commits at lists.llvm.org
Fri Dec 13 06:28:52 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 979e9361f0e0426e555c94cb8b1a64c655805765
https://github.com/llvm/llvm-project/commit/979e9361f0e0426e555c94cb8b1a64c655805765
Author: Peng Liu <winner245 at hotmail.com>
Date: 2024-12-13 (Fri, 13 Dec 2024)
Changed paths:
M libcxx/include/__split_buffer
M libcxx/include/deque
Log Message:
-----------
[libc++] Fix improper static_cast in std::deque and __split_buffer (#119106)
This PR addresses the improper use of `static_cast` to `size_t` where
`size_type` is intended. Although the `size_type` member type of STL
containers is usually a synonym of `std::size_t`, there is no guarantee
that they are always equivalent. The C++ standard does not mandate this
equivalence.
In libc++'s implementations of `std::deque`, `std::vector`, and
`__split_buffer`, the `size_type` member type is defined as
`std::allocator_traits<allocator_type>::size_type`, which is either
`allocator_type::size_type` if available or
`std::make_unsigned<difference_type>::type`. While it is true for
`std::allocator` that the `size_type` member type is `std::size_t`, for
user-defined allocator types, they may mismatch. This justifies the need
to replace `static_cast<size_t>` with `static_cast<size_type>` in this
PR.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list