diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-07-15 13:50:55 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-16 20:51:13 +0200 |
commit | 3099a6bf2add35ac6a0c7ce4cbb6c794d6269d19 (patch) | |
tree | 9d3e3e69d2e1929f9c4e07ab88ef11fadb5b8ddb /AK | |
parent | dd4ed4d22dc96737d8b0342886e24c9544fc1a63 (diff) | |
download | serenity-3099a6bf2add35ac6a0c7ce4cbb6c794d6269d19.zip |
Kernel+AK: Generate compile-time error for non-sized `delete`
This is a much more ergonomic option than getting a
`VERIFY_NOT_REACHED()` failure at run-time. I encountered this issue
with Clang, where sized deallocation is not the default due to ABI
breakage concerns.
Note that we can't simply just not declare these functions, because the
C++ standard states:
> If this function with size parameter is defined, the program shall
> also define the version without the size parameter.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Platform.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/AK/Platform.h b/AK/Platform.h index 2924f53cc3..8f9243f25f 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -59,6 +59,15 @@ #endif #define NAKED __attribute__((naked)) +#ifdef DISALLOW +# undef DISALLOW +#endif +#ifdef __clang__ +# define DISALLOW(message) __attribute__((diagnose_if(1, message, "error"))) +#else +# define DISALLOW(message) __attribute__((error(message))) +#endif + // GCC doesn't have __has_feature but clang does #ifndef __has_feature # define __has_feature(...) 0 |