From ff2a92809112a02bef3927ef25acd04bb4e0437a Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Fri, 3 Apr 2020 15:50:19 +0300 Subject: [PATCH] Work around ARM C 6 constexpr assert ARMC6's assert macro does not work in C++14 constexpr context as it should. By defining __DO_NOT_LINK_PROMISE_WITH_ASSERT, we deactivate the extension that breaks it (having `__promise` inside `assert` - see the compiler manual). The extension does not appear to be useful - we have no code using ARMC6's `__promise` directly, and putting a `__promise` inside the assert does not appear to affect code generation in my tests. --- platform/mbed_toolchain.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/mbed_toolchain.h b/platform/mbed_toolchain.h index a0fc28cf05..2fa91d69e2 100644 --- a/platform/mbed_toolchain.h +++ b/platform/mbed_toolchain.h @@ -24,6 +24,15 @@ #define __error_t_defined 1 #endif +/* Work around ARM Compiler 6 bug - assert does not work in constexpr + * functions unless you stop it from using its __promise built-in. + */ +#ifdef __ARMCC_VERSION +#ifndef __DO_NOT_LINK_PROMISE_WITH_ASSERT +#define __DO_NOT_LINK_PROMISE_WITH_ASSERT +#endif +#endif + // Warning for unsupported compilers #if !defined(__GNUC__) /* GCC */ \ && !defined(__clang__) /* LLVM/Clang */ \