From 00b9cdaf959254ab6e05433a2c173c546f9f41a5 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 5 Oct 2019 10:45:01 -0400 Subject: [PATCH 1/2] unfold UNREACHABLE implementation for dumb compilers We relies on UNREACHABLE's noreturn attribute to eliminate parent's "no return value" warning. However, this was wrapped in a `if(!false)` block, which compilers may not unfold to recognize the noreturn nature. --- src/common/assert.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/assert.h b/src/common/assert.h index 5c479f501..e2387a638 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -41,8 +41,8 @@ __declspec(noinline, noreturn) } \ while (0) -#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!") -#define UNREACHABLE_MSG(...) ASSERT_MSG(false, __VA_ARGS__) +#define UNREACHABLE() assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!"); }) +#define UNREACHABLE_MSG(...) assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); }) #ifdef _DEBUG #define DEBUG_ASSERT(_a_) ASSERT(_a_) From e1fbf90e1629d75db23df23b4ce0d0e39cb50a4c Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 5 Oct 2019 10:54:07 -0400 Subject: [PATCH 2/2] fix clang-format and lambda capture --- src/common/assert.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/assert.h b/src/common/assert.h index e2387a638..05e153326 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -42,7 +42,8 @@ __declspec(noinline, noreturn) while (0) #define UNREACHABLE() assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!"); }) -#define UNREACHABLE_MSG(...) assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); }) +#define UNREACHABLE_MSG(...) \ + assert_noinline_call([&] { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); }) #ifdef _DEBUG #define DEBUG_ASSERT(_a_) ASSERT(_a_)