From 785a26dc649af80c593f899a606dff4dae7c48fd Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Wed, 17 Oct 2018 17:37:41 +0000 Subject: Do not do null pointer arithmetic Let me introduce builtin function instead. This is a preparation CL to remove -Wno-null-pointer-arithmetic warning suppression. Bug: chromium:766891 Change-Id: I05434ba0c525fd2fddf916c042d1443b1f25d7d7 Reviewed-on: https://pdfium-review.googlesource.com/c/44191 Reviewed-by: Lei Zhang Commit-Queue: Lei Zhang --- third_party/base/logging.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/third_party/base/logging.h b/third_party/base/logging.h index 2aeca31b85..76555f563e 100644 --- a/third_party/base/logging.h +++ b/third_party/base/logging.h @@ -9,16 +9,15 @@ #include #ifndef _WIN32 -#define NULL_DEREF_IF_POSSIBLE \ - *(reinterpret_cast(NULL) + 42) = 0x42; +#define NULL_DEREF_IF_POSSIBLE __builtin_unreachable() #else -#define NULL_DEREF_IF_POSSIBLE +#define NULL_DEREF_IF_POSSIBLE __assume(0) #endif #define CHECK(condition) \ if (!(condition)) { \ abort(); \ - NULL_DEREF_IF_POSSIBLE \ + NULL_DEREF_IF_POSSIBLE;\ } // TODO(palmer): These are quick hacks to import PartitionAlloc with minimum -- cgit v1.2.3