Merge branch 'fix-Wnull-pointer-arithmetic' into Mesh_3-stop_during_protection-lrineau

This commit is contained in:
Laurent Rineau 2019-05-02 14:46:49 +02:00
commit f34231dab6
1 changed files with 13 additions and 8 deletions

View File

@ -32,6 +32,7 @@
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstddef>
#include <CGAL/Compact_container.h>
@ -641,7 +642,8 @@ private:
static char * clean_pointer(char * p)
{
return ((p - (char *) NULL) & ~ (std::ptrdiff_t) START_END) + (char *) NULL;
return reinterpret_cast<char*>(reinterpret_cast<std::ptrdiff_t>(p) &
~ (std::ptrdiff_t) START_END);
}
// Returns the pointee, cleaned up from the squatted bits.
@ -654,20 +656,23 @@ private:
static Type type(const_pointer ptr)
{
char * p = (char *) Traits::pointer(*ptr);
return (Type) (p - clean_pointer(p));
return (Type) (reinterpret_cast<std::ptrdiff_t>(p) -
reinterpret_cast<std::ptrdiff_t>(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<void *>
(reinterpret_cast<std::ptrdiff_t>(clean_pointer((char *) p)) + (int) t);
}
typedef tbb::queuing_mutex Mutex;