From c79aa6ad8accb1c00823be410205bd21bfe9609a Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Thu, 6 Jul 2023 18:03:37 +0200 Subject: [PATCH] all: cosmetic updates --- .github/workflows/ci.yml | 4 +- .github/workflows/weekly-ci-zigcc.yml | 4 +- CMakeLists.txt | 166 ++++++++++++++------------ Makefile | 3 +- misc/scripts/build_upx_by_hand.sh | 2 + src/check/dt_check.cpp | 5 +- src/check/dt_impl.cpp | 1 + src/util/membuffer.h | 14 ++- src/util/xspan.h | 6 + src/util/xspan_fwd.h | 12 +- src/util/xspan_impl.h | 32 +++-- src/util/xspan_impl_common.h | 4 +- src/util/xspan_impl_ptr.h | 6 +- src/util/xspan_impl_ptr_or_null.h | 2 +- 14 files changed, 155 insertions(+), 106 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b1be8c2..96f76a00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,8 @@ on: [push, workflow_dispatch] env: DEBIAN_FRONTEND: noninteractive UPX_CMAKE_BUILD_FLAGS: --verbose - # 2023-06-29 - ZIG_DIST_VERSION: 0.11.0-dev.3886+0c1bfe271 + # 2023-07-05 + ZIG_DIST_VERSION: 0.11.0-dev.3937+78eb3c561 jobs: job-rebuild-and-verify-stubs: diff --git a/.github/workflows/weekly-ci-zigcc.yml b/.github/workflows/weekly-ci-zigcc.yml index 4005519a..c9acfa0d 100644 --- a/.github/workflows/weekly-ci-zigcc.yml +++ b/.github/workflows/weekly-ci-zigcc.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: env: - # 2023-06-29 - ZIG_DIST_VERSION: 0.11.0-dev.3886+0c1bfe271 + # 2023-07-05 + ZIG_DIST_VERSION: 0.11.0-dev.3937+78eb3c561 jobs: job-linux-zigcc: # uses cmake + make diff --git a/CMakeLists.txt b/CMakeLists.txt index ebc14620..ba840458 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,11 +120,97 @@ if(is_multi_config) set(CMAKE_CONFIGURATION_TYPES "${c}" CACHE STRING "List of supported configuration types." FORCE) endif() +# set MSVC_FRONTEND set(MSVC_FRONTEND 0) if(MSVC OR ",${CMAKE_C_COMPILER_FRONTEND_VARIANT}," STREQUAL ",MSVC,") set(MSVC_FRONTEND 1) endif() +#*********************************************************************** +# common compilation flags +#*********************************************************************** + +if(UPX_CONFIG_DISABLE_WSTRICT) + # enable all basic warnings + set(warn_Wall -Wall) + set(warn_WN -W3) +else() + # enable all basic warnings, and enable lots of strict warnings + set(warn_Wall -Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings) + set(warn_WN -W4) +endif() +if(UPX_CONFIG_DISABLE_WERROR) + # warnings are just warnings + set(warn_Werror "") + set(warn_WX "") +else() + # warnings are fatal errors; annoy developers to keep the source code warning-free + set(warn_Werror -Werror) + set(warn_WX -WX) +endif() + +if(NOT MSVC) + # use -O2 instead of -O3 to reduce code size + string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" a "${CMAKE_C_FLAGS_RELEASE}") + string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" b "${CMAKE_CXX_FLAGS_RELEASE}") + set(CMAKE_C_FLAGS_RELEASE "${a}" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE) + set(CMAKE_CXX_FLAGS_RELEASE "${b}" CACHE STRING "Flags used by the CXX compiler during RELEASE builds." FORCE) +endif() + +if(MSVC_FRONTEND) + # disable silly warnings about using "deprecated" POSIX functions like fopen() + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + # use -funsigned-char; set __cplusplus according to selected C++ standard; use new preprocessor + add_definitions(-J -Zc:__cplusplus -Zc:preprocessor) +else() + # protect against security threats caused by misguided compiler "optimizations" + if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + add_definitions(-fno-delete-null-pointer-checks -fno-lifetime-dse) + endif() + add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char) + # disable overambitious auto-vectorization until this actually gains something + add_definitions(-fno-tree-vectorize) + # disable annoying clang warnings which get added by the Apple Xcode cmake generator + if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_GENERATOR STREQUAL "Xcode") + add_definitions(-Wno-shorten-64-to-32) + endif() +endif() + +# compile a target with -O2 even in Debug build +function(upx_compile_target_debug_with_O2) + foreach(t ${ARGV}) + if(MSVC_FRONTEND) + # MSVC uses some Debug compilation options like -RTC1 that are incompatible with -O2 + else() + target_compile_options(${t} PRIVATE $<$:-O2>) + endif() + endforeach() +endfunction() + +# sanitize a target +function(upx_sanitize_target) + foreach(t ${ARGV}) + if(UPX_CONFIG_DISABLE_SANITIZE) + # no-op + elseif(MSVC_FRONTEND) + # MSVC uses -GS (similar to -fstack-protector) by default + elseif(CMAKE_C_PLATFORM_ID MATCHES "^MinGW" OR MINGW OR CYGWIN) + # avoid link errors with current MinGW-w64 versions + # see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan + else() + # default sanitizer for Debug builds + target_compile_options(${t} PRIVATE $<$:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>) + # default sanitizer for Release builds + target_compile_options(${t} PRIVATE $<$:-fstack-protector>) + target_compile_options(${t} PRIVATE $<$:-fstack-protector>) + target_compile_options(${t} PRIVATE $<$:-fstack-protector>) + endif() + endforeach() +endfunction() + #*********************************************************************** # targets #*********************************************************************** @@ -188,87 +274,9 @@ if(Threads_FOUND) endif() #*********************************************************************** -# compilation flags +# target compilation flags #*********************************************************************** -if(UPX_CONFIG_DISABLE_WSTRICT) - # enable all basic warnings - set(warn_Wall -Wall) - set(warn_WN -W3) -else() - # enable lots of strict warnings - set(warn_Wall -Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings) - set(warn_WN -W4) -endif() -if(UPX_CONFIG_DISABLE_WERROR) - set(warn_Werror "") - set(warn_WX "") -else() - set(warn_Werror -Werror) - set(warn_WX -WX) -endif() - -if(NOT MSVC) - # use -O2 instead of -O3 to reduce code size - string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" a "${CMAKE_C_FLAGS_RELEASE}") - string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" b "${CMAKE_CXX_FLAGS_RELEASE}") - set(CMAKE_C_FLAGS_RELEASE "${a}" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE) - set(CMAKE_CXX_FLAGS_RELEASE "${b}" CACHE STRING "Flags used by the CXX compiler during RELEASE builds." FORCE) -endif() - -if(MSVC_FRONTEND) - # disable silly warnings about using "deprecated" POSIX functions like fopen() - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - # set __cplusplus according to selected C++ standard; use new preprocessor - add_definitions(-J -Zc:__cplusplus -Zc:preprocessor) -else() - # protect against security threats caused by misguided compiler "optimizations" - if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - add_definitions(-fno-delete-null-pointer-checks -fno-lifetime-dse) - endif() - add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char) - # disable overambitious auto-vectorization until this actually gains something - add_definitions(-fno-tree-vectorize) - # disable annoying clang warnings which get added by the Apple Xcode cmake generator - if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_GENERATOR STREQUAL "Xcode") - add_definitions(-Wno-shorten-64-to-32) - endif() -endif() - -# compile a target with -O2 even in Debug build -function(upx_compile_target_debug_with_O2) - foreach(t ${ARGV}) - if(MSVC_FRONTEND) - # MSVC uses some Debug compilation options like -RTC1 that are incompatible with -O2 - else() - target_compile_options(${t} PRIVATE $<$:-O2>) - endif() - endforeach() -endfunction() - -function(upx_sanitize_target) - foreach(t ${ARGV}) - if(UPX_CONFIG_DISABLE_SANITIZE) - # no-op - elseif(MSVC_FRONTEND) - # MSVC uses -GS (similar to -fstack-protector) by default - elseif(CMAKE_C_PLATFORM_ID MATCHES "^MinGW" OR MINGW OR CYGWIN) - # avoid link errors with current MinGW-w64 versions - # see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan - else() - # default sanitizer for Debug builds - target_compile_options(${t} PRIVATE $<$:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>) - # default sanitizer for Release builds - target_compile_options(${t} PRIVATE $<$:-fstack-protector>) - target_compile_options(${t} PRIVATE $<$:-fstack-protector>) - target_compile_options(${t} PRIVATE $<$:-fstack-protector>) - endif() - endforeach() -endfunction() - if(NOT UPX_CONFIG_DISABLE_BZIP2) set(t upx_vendor_bzip2) upx_compile_target_debug_with_O2(${t}) diff --git a/Makefile b/Makefile index 549e0253..7582c86d 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,9 @@ # # INFO: this Makefile is just a convenience wrapper for calling CMake +# (using a somewhat current CMake version is highly recommended) -# NOTE: if you only have an older CMake 3.x then you can invoke cmake manually like this: +# HINT: if you only have an older CMake 3.x then you can invoke cmake manually like this: # mkdir -p build/release # cd build/release # cmake ../.. diff --git a/misc/scripts/build_upx_by_hand.sh b/misc/scripts/build_upx_by_hand.sh index cc8a1fe0..b71e8eeb 100755 --- a/misc/scripts/build_upx_by_hand.sh +++ b/misc/scripts/build_upx_by_hand.sh @@ -37,7 +37,9 @@ CXX="$CXX $mandatory_flags" # HINT: set "top_srcdir" manually if your system does not have "readlink" if test "x$top_srcdir" = "x"; then my_argv0abs="$(readlink -fn "$my_argv0")" + test "x$my_argv0abs" = "x" && exit 1 my_argv0dir="$(dirname "$my_argv0abs")" + test "x$my_argv0dir" = "x" && exit 1 cd "$my_argv0dir/../.." || exit 1 else cd "$top_srcdir" || exit 1 diff --git a/src/check/dt_check.cpp b/src/check/dt_check.cpp index 1d8a25ec..d3ad5920 100644 --- a/src/check/dt_check.cpp +++ b/src/check/dt_check.cpp @@ -175,6 +175,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER((wchar_t) -1 > 0) /************************************************************************* // upx_compiler_sanity_check() // assert a sane architecture and compiler +// (modern compilers will optimize away most of this code) **************************************************************************/ namespace { @@ -287,7 +288,7 @@ struct TestBELE { static noinline bool test(void) { CheckIntegral::check(); CheckAlignment::check(); - // arithmetic checks (modern compilers will optimize this away) + // arithmetic checks T allbits = {}; assert(allbits == 0); allbits += 1; @@ -544,7 +545,7 @@ TEST_CASE("noncopyable") { }; Test t = {}; CHECK(t.v == 1); -#if (ACC_CC_MSC) // MSVC thinks that Test is not std::is_trivially_copyable; compiler bug? +#if (ACC_CC_MSC) // MSVC thinks that Test is not std::is_trivially_copyable; true or compiler bug? t.v = 0; #else mem_clear(&t); diff --git a/src/check/dt_impl.cpp b/src/check/dt_impl.cpp index b0a349a7..477729ba 100644 --- a/src/check/dt_impl.cpp +++ b/src/check/dt_impl.cpp @@ -53,6 +53,7 @@ #endif #include + #endif // DOCTEST_CONFIG_DISABLE /* vim:set ts=4 sw=4 et: */ diff --git a/src/util/membuffer.h b/src/util/membuffer.h index 7bb4cc8f..4f77f4f9 100644 --- a/src/util/membuffer.h +++ b/src/util/membuffer.h @@ -51,7 +51,7 @@ public: inline MemBufferBase() noexcept : ptr(nullptr), size_in_bytes(0) {} inline ~MemBufferBase() noexcept {} - // NOTE: implicit conversion to underlying pointer + // IMPORTANT NOTE: automatic conversion to underlying pointer // HINT: for fully bound-checked pointer use XSPAN_S from xspan.h operator pointer() const noexcept { return ptr; } @@ -61,7 +61,6 @@ public: size_t bytes = mem_size(sizeof(T), n); // check mem_size return raw_bytes(bytes) + n; // and check bytes } - private: // membuffer - n -> pointer; not allowed - use raw_bytes() if needed template @@ -94,7 +93,7 @@ private: // global operators #if ALLOW_INT_PLUS_MEMBUFFER -// rewrite "n + membuffer" to "membuffer + n" so that this will get checked above +// rewrite "n + membuffer" to "membuffer + n" (member function) so that this will get checked above template inline typename std::enable_if::value, typename MemBufferBase::pointer>::type operator+(U n, const MemBufferBase &mbb) { @@ -121,8 +120,17 @@ inline typename MemBufferBase::pointer raw_index_bytes(const MemBufferBase } // some more global overloads using a checked raw_bytes() call +#if __cplusplus >= 201703L +#define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \ + std::enable_if_t || std::is_convertible_v, RType> +#elif __cplusplus >= 201103L +#define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \ + typename std::enable_if< \ + std::is_convertible::value || std::is_convertible::value, RType>::type +#else #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \ typename std::enable_if::value, RType>::type +#endif #define C MemBufferBase #define XSPAN_FWD_C_IS_MEMBUFFER 1 #if WITH_XSPAN >= 1 diff --git a/src/util/xspan.h b/src/util/xspan.h index 4a991e41..cf6b9813 100644 --- a/src/util/xspan.h +++ b/src/util/xspan.h @@ -80,6 +80,7 @@ using XSPAN_NAMESPACE_NAME::raw_index_bytes; // overloaded for all classes // fully checked +// types #define XSPAN_0(type) PtrOrSpanOrNull #define XSPAN_P(type) PtrOrSpan #define XSPAN_S(type) Span @@ -98,6 +99,7 @@ using XSPAN_NAMESPACE_NAME::raw_index_bytes; // overloaded for all classes // unchecked - just a no-op pointer wrapper, no extra functionality +// types #define XSPAN_0(type) Ptr #define XSPAN_P(type) Ptr #define XSPAN_S(type) Ptr @@ -130,6 +132,7 @@ inline R *xspan_make_helper__(R * /*dummy*/, MemBuffer &mb) noexcept { return (R *) membuffer_get_void_ptr(mb); } +// types #define XSPAN_0(type) type * #define XSPAN_P(type) type * #define XSPAN_S(type) type * @@ -151,12 +154,15 @@ inline R *xspan_make_helper__(R * /*dummy*/, MemBuffer &mb) noexcept { **************************************************************************/ #if 1 +// types #define SPAN_0 XSPAN_0 #define SPAN_P XSPAN_P #define SPAN_S XSPAN_S +// create a value #define SPAN_0_MAKE XSPAN_0_MAKE #define SPAN_P_MAKE XSPAN_P_MAKE #define SPAN_S_MAKE XSPAN_S_MAKE +// define a variable #define SPAN_0_VAR XSPAN_0_VAR #define SPAN_P_VAR XSPAN_P_VAR #define SPAN_S_VAR XSPAN_S_VAR diff --git a/src/util/xspan_fwd.h b/src/util/xspan_fwd.h index 8787d939..82c6a6b5 100644 --- a/src/util/xspan_fwd.h +++ b/src/util/xspan_fwd.h @@ -24,14 +24,22 @@ */ -// manually forward a number of well-known functions using a -// checked "raw_bytes()" call +// manually forward a number of well-known functions using a checked "raw_bytes()" call +// +// uses C +// uses optional D, E and XSPAN_FWD_C_IS_MEMBUFFER +// needs XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION +// +// example for a default implementation: +// #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) +// std::enable_if_t || std::is_convertible_v, RType> #define XSPAN_FWD_TU(RType) \ template \ inline XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(T, U, RType) #ifndef XSPAN_FWD_C_IS_MEMBUFFER +// global operator: disallow "n + C" => force using "C + n" (member function) instead template inline typename std::enable_if::value, void *>::type operator+(U, const C &) XSPAN_DELETED_FUNCTION; diff --git a/src/util/xspan_impl.h b/src/util/xspan_impl.h index 8afc025b..f6f63344 100644 --- a/src/util/xspan_impl.h +++ b/src/util/xspan_impl.h @@ -52,11 +52,11 @@ void xspan_check_range(const void *p, const void *base, ptrdiff_t size_in_bytes) // help constructor to distinguish between number of elements and bytes struct XSpanCount { - explicit XSpanCount(size_t n) noexcept : count(n) {} + explicit forceinline XSpanCount(size_t n) noexcept : count(n) {} size_t count; // public }; struct XSpanSizeInBytes { - explicit XSpanSizeInBytes(size_t bytes) noexcept : size_in_bytes(bytes) {} + explicit forceinline XSpanSizeInBytes(size_t bytes) noexcept : size_in_bytes(bytes) {} size_t size_in_bytes; // public }; @@ -109,12 +109,16 @@ inline void xspan_mem_size_assert_ptrdiff(ptrdiff_t n) { (void) xspan_mem_size((size_t) -n); } -#if 0 +#if __cplusplus >= 201103L && 0 +// unfortunately doesnt't work with some older versions of libstdc++ +// (TODO later: we now require C++17, so this now probably works on all supported platforms) template struct XSpan_is_convertible : public std::is_convertible {}; #else +// manual implementation namespace detail { +// helper for "void" template struct XSpan_void_to_T { typedef U type; @@ -125,7 +129,6 @@ struct XSpan_void_to_T { }; template struct XSpan_void_to_T { - // typedef typename std::add_const::type type; typedef T type; }; @@ -180,7 +183,6 @@ ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible::value)) **************************************************************************/ // forward declarations - template struct PtrOrSpanOrNull; template @@ -190,13 +192,24 @@ struct Span; template struct Ptr; -class XSpanInternalDummyArg; // not implemented +// XSpanInternalDummyArg: some type that is hard to match by accident +class XSpanInternalDummyArgFake; // not implemented on purpose +#if 0 +typedef XSpanInternalDummyArgFake *XSpanInternalDummyArg; +#define XSpanInternalDummyArgInit nullptr +#else +struct XSpanInternalDummyArg { + explicit forceinline XSpanInternalDummyArg(int, XSpanInternalDummyArgFake *) noexcept {} +}; +#define XSpanInternalDummyArgInit (XSPAN_NS(XSpanInternalDummyArg)(0, nullptr)) +#endif XSPAN_NAMESPACE_END #ifndef XSPAN_DELETED_FUNCTION #define XSPAN_DELETED_FUNCTION = delete #endif +// function/method constraints #define XSPAN_REQUIRES_CONVERTIBLE_ONE_DIRECTION(From, To, RType) \ typename std::enable_if::value, RType > ::type #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \ @@ -206,15 +219,16 @@ XSPAN_NAMESPACE_END // note: these use "T" and "U" #define XSPAN_REQUIRES_CONVERTIBLE_R(RType) XSPAN_REQUIRES_CONVERTIBLE_ONE_DIRECTION(U, T, RType) #define XSPAN_REQUIRES_CONVERTIBLE_A \ - XSPAN_REQUIRES_CONVERTIBLE_R(XSPAN_NS(XSpanInternalDummyArg) *) = nullptr -#define XSPAN_REQUIRES_CONVERTIBLE_T XSPAN_REQUIRES_CONVERTIBLE_R(XSPAN_NS(XSpanInternalDummyArg) *) + XSPAN_REQUIRES_CONVERTIBLE_R(XSPAN_NS(XSpanInternalDummyArg)) = XSpanInternalDummyArgInit +#define XSPAN_REQUIRES_CONVERTIBLE_T XSPAN_REQUIRES_CONVERTIBLE_R(XSPAN_NS(XSpanInternalDummyArg)) // note: these use "T" and "U" #define XSPAN_REQUIRES_SIZE_1_R(RType) \ typename std::enable_if::value &&XSPAN_NS( \ ValueForSizeOf)::value == 1 && \ XSPAN_NS(ValueForSizeOf)::value == 1, \ RType > ::type -#define XSPAN_REQUIRES_SIZE_1_A XSPAN_REQUIRES_SIZE_1_R(XSPAN_NS(XSpanInternalDummyArg) *) = nullptr +#define XSPAN_REQUIRES_SIZE_1_A \ + XSPAN_REQUIRES_SIZE_1_R(XSPAN_NS(XSpanInternalDummyArg)) = XSpanInternalDummyArgInit #include "xspan_impl_ptr_or_null.h" #include "xspan_impl_ptr_or_span.h" diff --git a/src/util/xspan_impl_common.h b/src/util/xspan_impl_common.h index f9733914..16479e38 100644 --- a/src/util/xspan_impl_common.h +++ b/src/util/xspan_impl_common.h @@ -68,7 +68,7 @@ private: xspan_check_range(ptr, base, size_in_bytes); } #else -inline void assertInvariants() const noexcept {} +forceinline void assertInvariants() const noexcept {} #endif static inline pointer makeNotNull(pointer p) { @@ -103,7 +103,7 @@ public: #if DEBUG inline ~CSelf() { invalidate(); } #else -inline ~CSelf() noexcept {} +forceinline ~CSelf() noexcept {} #endif noinline void invalidate() { assertInvariants(); diff --git a/src/util/xspan_impl_ptr.h b/src/util/xspan_impl_ptr.h index cc4ad3b2..758b299d 100644 --- a/src/util/xspan_impl_ptr.h +++ b/src/util/xspan_impl_ptr.h @@ -182,9 +182,9 @@ public: #endif private: - forceinline pointer check_deref(pointer p) const { return p; } - forceinline pointer check_deref(pointer p, ptrdiff_t n) const { return p + n; } - forceinline pointer check_add(pointer p, ptrdiff_t n) const { return p + n; } + static forceinline pointer check_deref(pointer p) noexcept { return p; } + static forceinline pointer check_deref(pointer p, ptrdiff_t n) noexcept { return p + n; } + static forceinline pointer check_add(pointer p, ptrdiff_t n) noexcept { return p + n; } public: // raw access pointer raw_ptr() const noexcept { return ptr; } diff --git a/src/util/xspan_impl_ptr_or_null.h b/src/util/xspan_impl_ptr_or_null.h index 5809b2e0..7e8a82a8 100644 --- a/src/util/xspan_impl_ptr_or_null.h +++ b/src/util/xspan_impl_ptr_or_null.h @@ -86,7 +86,7 @@ public: } // nullptr - CSelf(std::nullptr_t) : ptr(nullptr), base(nullptr), size_in_bytes(0) {} + forceinline CSelf(std::nullptr_t) noexcept : ptr(nullptr), base(nullptr), size_in_bytes(0) {} #undef CSelf };