From 19527dc384d15de0b2dd8b3ca1af9d6563c47860 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 2 May 2019 14:36:26 +0200 Subject: [PATCH] Fix AppleClang -Wnull-pointer-arithmetic warning with TBB as well --- .../CGAL/Concurrent_compact_container.h | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 57aec68df0f..bdcd71cede3 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -633,7 +634,8 @@ private: static char * clean_pointer(char * p) { - return ((p - (char *) NULL) & ~ (std::ptrdiff_t) START_END) + (char *) NULL; + return reinterpret_cast(reinterpret_cast(p) & + ~ (std::ptrdiff_t) START_END); } // Returns the pointee, cleaned up from the squatted bits. @@ -646,20 +648,23 @@ private: static Type type(const_pointer ptr) { char * p = (char *) Traits::pointer(*ptr); - return (Type) (p - clean_pointer(p)); + return (Type) (reinterpret_cast(p) - + reinterpret_cast(clean_pointer(p))); } - static Type type(const_iterator ptr) + static Type type(const_iterator it) { - return type(&*ptr); + return type(it.operator->()); } // Sets the pointer part and the type of the pointee. - static void set_type(pointer p_element, void * pointer, Type t) + static void set_type(pointer ptr, void * p, Type t) { - CGAL_precondition(0 <= t && (int) t < 4); - Traits::pointer(*p_element) = - (void *) ((clean_pointer((char *) pointer)) + (int) t); + // This out of range compare is always true and causes lots of + // unnecessary warnings. + // CGAL_precondition(0 <= t && t < 4); + Traits::pointer(*ptr) = reinterpret_cast + (reinterpret_cast(clean_pointer((char *) p)) + (int) t); } typedef tbb::queuing_mutex Mutex;