diff --git a/AK/Assertions.h b/AK/Assertions.h index 55e7c989da..648d9b9d49 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -10,8 +10,15 @@ # include #else # include -# define VERIFY assert -# define VERIFY_NOT_REACHED() assert(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */ +# ifndef NDEBUG +# define VERIFY assert +# else +# define VERIFY(expr) \ + (__builtin_expect(!(expr), 0) \ + ? __builtin_trap() \ + : (void)0) +# endif +# define VERIFY_NOT_REACHED() VERIFY(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */ static constexpr bool TODO = false; # define TODO() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */ #endif