mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-14 18:33:16 +08:00
Implement a better workaround for GCC's bug #87544
This commit is contained in:
parent
409132bb81
commit
6512c5e136
@ -884,18 +884,19 @@ public:
|
|||||||
|
|
||||||
~aligned_allocator() {}
|
~aligned_allocator() {}
|
||||||
|
|
||||||
|
#if EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_LEAST(7,0)
|
||||||
|
// In gcc std::allocator::max_size() is bugged making gcc triggers a warning:
|
||||||
|
// eigen/Eigen/src/Core/util/Memory.h:189:12: warning: argument 1 value '18446744073709551612' exceeds maximum object size 9223372036854775807
|
||||||
|
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87544
|
||||||
|
size_type max_size() const {
|
||||||
|
return (std::numeric_limits<std::ptrdiff_t>::max)()/sizeof(T);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pointer allocate(size_type num, const void* /*hint*/ = 0)
|
pointer allocate(size_type num, const void* /*hint*/ = 0)
|
||||||
{
|
{
|
||||||
internal::check_size_for_overflow<T>(num);
|
internal::check_size_for_overflow<T>(num);
|
||||||
size_type size = num * sizeof(T);
|
return static_cast<pointer>( internal::aligned_malloc(num * sizeof(T)) );
|
||||||
#if EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_LEAST(7,0)
|
|
||||||
// workaround gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87544
|
|
||||||
// It triggered eigen/Eigen/src/Core/util/Memory.h:189:12: warning: argument 1 value '18446744073709551612' exceeds maximum object size 9223372036854775807
|
|
||||||
if(size>=std::size_t((std::numeric_limits<std::ptrdiff_t>::max)()))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
return static_cast<pointer>( internal::aligned_malloc(size) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(pointer p, size_type /*num*/)
|
void deallocate(pointer p, size_type /*num*/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user