Skip to content

Commit ff2a928

Browse files
committed
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.
1 parent d1ae0d5 commit ff2a928

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

platform/mbed_toolchain.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
#define __error_t_defined 1
2525
#endif
2626

27+
/* Work around ARM Compiler 6 bug - assert does not work in constexpr
28+
* functions unless you stop it from using its __promise built-in.
29+
*/
30+
#ifdef __ARMCC_VERSION
31+
#ifndef __DO_NOT_LINK_PROMISE_WITH_ASSERT
32+
#define __DO_NOT_LINK_PROMISE_WITH_ASSERT
33+
#endif
34+
#endif
35+
2736
// Warning for unsupported compilers
2837
#if !defined(__GNUC__) /* GCC */ \
2938
&& !defined(__clang__) /* LLVM/Clang */ \

0 commit comments

Comments
 (0)