[libcxx-commits] [libcxx] [libcxx] Align allocation to match `__set_long_cap` and `__get_long_cap` (PR #90292)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 1 23:15:14 PDT 2024


philnik777 wrote:

> > _LIBCPP_ASSERT_INTERNAL
> 
> Done, but I am curious why this can be wrong? Seems set/get should return exactly the same value.

As I tried to explain before, `__allocate_at_least` may return more bytes than we requested with a custom allocator - possibly (even though unlikely) an odd number of elements. Since we drop the last bit of our capacity, we have no choice but to drop the last element of that allocation.

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


More information about the libcxx-commits mailing list