From 409132bb817f2a3f77e0a0ecb9baeb73af386984 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sun, 7 Oct 2018 09:23:15 +0200 Subject: Workaround gcc bug making it trigger an invalid warning --- Eigen/src/Core/util/Memory.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Eigen/src/Core/util/Memory.h') diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index c624556c5..46a0dbc69 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -887,7 +887,15 @@ public: pointer allocate(size_type num, const void* /*hint*/ = 0) { internal::check_size_for_overflow(num); - return static_cast( internal::aligned_malloc(num * sizeof(T)) ); + size_type size = 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::max)())) + return 0; + else +#endif + return static_cast( internal::aligned_malloc(size) ); } void deallocate(pointer p, size_type /*num*/) -- cgit v1.2.3