1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:37:35 +00:00

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.
This commit is contained in:
Daniel Bertalan 2021-07-15 13:50:55 +02:00 committed by Andreas Kling
parent dd4ed4d22d
commit 3099a6bf2a
2 changed files with 12 additions and 2 deletions

View file

@ -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