Invalid aligned_alloc
Closed this issue · 1 comments
bmanga commented
The code contains a call to aligned_alloc for the aligned_array class:
std::aligned_alloc(alignment, sizeof(type_) * size_)In the sorting test, with size = 3, the values are: alignment = 64 size = 3, sizeof(uint32_t) = 4.
This results in a call with alignment = 64, size = 12.
According to https://en.cppreference.com/w/cpp/memory/c/aligned_alloc size should be a multiple of alignment, or nullptr is returned.
On mac os (arm64), it indeed returns nullptr and a std::bad_alloc is thrown.
(Similar problem when sorting 8196 elements)
ashvardanian commented
Thanks for spotting! Would you be able to submit a patch, @bmanga?