mirror of https://github.com/CGAL/cgal
Merge pull request #3824 from lrineau/fix-Wnull-pointer-arithmetic
Fix AppleClang -Wnull-pointer-arithmetic warning
This commit is contained in:
commit
f40550fef3
|
|
@ -28,6 +28,7 @@
|
||||||
#include <CGAL/Default.h>
|
#include <CGAL/Default.h>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -815,7 +816,8 @@ private:
|
||||||
|
|
||||||
static char * clean_pointer(char * p)
|
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.
|
// Returns the pointee, cleaned up from the squatted bits.
|
||||||
|
|
@ -828,7 +830,8 @@ private:
|
||||||
static Type type(const_pointer ptr)
|
static Type type(const_pointer ptr)
|
||||||
{
|
{
|
||||||
char * p = (char *) Traits::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.
|
// 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
|
// This out of range compare is always true and causes lots of
|
||||||
// unnecessary warnings.
|
// unnecessary warnings.
|
||||||
// CGAL_precondition(0 <= t && t < 4);
|
// 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:
|
public:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue