mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 20:04:29 +02:00
Work around bugs in gcc's analysis
Under `-m32 -O3` builds, it seems like gcc gets confused by the usage of malloc and calloc so we opt into the C++ versions, operator new and delete
This commit is contained in:
@@ -35,8 +35,8 @@ template <typename T> struct test_allocator
|
|||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
test_allocator() = default;
|
test_allocator() = default;
|
||||||
template <typename T2> test_allocator(test_allocator<T2> const&) {}
|
template <typename T2> test_allocator(test_allocator<T2> const&) {}
|
||||||
T* allocate(std::size_t n) const { return (T*)malloc(sizeof(T) * n); }
|
T* allocate(std::size_t n) const { return (T*)(::operator new(sizeof(T) * n)); }
|
||||||
void deallocate(T* ptr, std::size_t) const { free(ptr); }
|
void deallocate(T* ptr, std::size_t) const { ::operator delete(ptr); }
|
||||||
bool operator==(test_allocator const&) const { return true; }
|
bool operator==(test_allocator const&) const { return true; }
|
||||||
bool operator!=(test_allocator const&) const { return false; }
|
bool operator!=(test_allocator const&) const { return false; }
|
||||||
};
|
};
|
||||||
|
@@ -30,13 +30,13 @@ template <typename T> struct A
|
|||||||
{
|
{
|
||||||
total_allocation += n * sizeof(T);
|
total_allocation += n * sizeof(T);
|
||||||
++num_allocations;
|
++num_allocations;
|
||||||
return (T*)std::calloc(n, sizeof(T));
|
return (T*)(::operator new(n * sizeof(T)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(T* p, std::size_t n) noexcept
|
void deallocate(T* p, std::size_t n) noexcept
|
||||||
{
|
{
|
||||||
total_allocation -= n * sizeof(T);
|
total_allocation -= n * sizeof(T);
|
||||||
std::free(p);
|
::operator delete(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(A const& a) const { return i == a.i; }
|
bool operator==(A const& a) const { return i == a.i; }
|
||||||
|
Reference in New Issue
Block a user