From 604d2fd1ffcd0072958ba53b606d80fe7b993883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Oct 2021 15:19:05 +0200 Subject: [PATCH] direct definition the extra if was generating fallthru warnings --- Installation/include/CGAL/config.h | 4 +++- STL_Extension/include/CGAL/assertions.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 33350489671..daab1608122 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -369,15 +369,17 @@ using std::max; # define CGAL_NO_UNIQUE_ADDRESS #endif -// Macro CGAL_ASSUME +// Macro CGAL_ASSUME and CGAL_unreachable // Call a builtin of the compiler to pass a hint to the compiler #if __has_builtin(__builtin_unreachable) || (CGAL_GCC_VERSION > 0 && !__STRICT_ANSI__) // From g++ 4.5, there exists a __builtin_unreachable() // Also in LLVM/clang # define CGAL_ASSUME(EX) if(!(EX)) { __builtin_unreachable(); } +# define CGAL_unreachable() __builtin_unreachable() #elif defined(_MSC_VER) // MSVC has __assume # define CGAL_ASSUME(EX) __assume(EX) +# define CGAL_unreachable() __assume(0) #endif // If CGAL_ASSUME is not defined, then CGAL_assume and CGAL_assume_code are // defined differently, in diff --git a/STL_Extension/include/CGAL/assertions.h b/STL_Extension/include/CGAL/assertions.h index f76fdb967e1..293a2abe557 100644 --- a/STL_Extension/include/CGAL/assertions.h +++ b/STL_Extension/include/CGAL/assertions.h @@ -84,6 +84,7 @@ inline bool possibly(Uncertain c); # define CGAL_assume_code(CODE) CODE # else // not def CGAL_ASSUME # define CGAL_assume(EX) CGAL_assertion(EX) +# define CGAL_unreachable() CGAL_assertion(false) # define CGAL_assume_code(CODE) CGAL_assertion_code(CODE) # endif // not def CGAL_ASSUME #else // no CGAL_NO_ASSERTIONS @@ -106,8 +107,6 @@ inline bool possibly(Uncertain c); # define CGAL_assume_code(CODE) CGAL_assertion_code(CODE) #endif // no CGAL_NO_ASSERTIONS -#define CGAL_unreachable() CGAL_assume(false) - # define CGAL_static_assertion(EX) \ static_assert(EX, #EX)