Merge pull request #3824 from lrineau/fix-Wnull-pointer-arithmetic

Fix AppleClang -Wnull-pointer-arithmetic warning
This commit is contained in:
Laurent Rineau 2019-04-08 15:57:34 +02:00
commit f40550fef3
1 changed files with 7 additions and 3 deletions

View File

@ -28,6 +28,7 @@
#include <CGAL/Default.h>
#include <cmath>
#include <cstddef>
#include <iterator>
#include <algorithm>
#include <vector>
@ -815,7 +816,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.
@ -828,7 +830,8 @@ 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)));
}
// Sets the pointer part and the type of the pointee.
@ -837,7 +840,8 @@ private:
// This out of range compare is always true and causes lots of
// unnecessary warnings.
// CGAL_precondition(0 <= t && t < 4);
Traits::pointer(*ptr) = (void *) ((clean_pointer((char *) p)) + (int) t);
Traits::pointer(*ptr) = reinterpret_cast<void *>
(reinterpret_cast<std::ptrdiff_t>(clean_pointer((char *) p)) + (int) t);
}
public: