Add noreturn attribute to crash()

Since crash() stops the program, adding the `noreturn` attribute allows the compiler to optimize in certain cases. CLion and ReSharper also use this in its static analysis engine to warn about unreachable code. Additionally, since `assert()` uses `crash()` if the checked pointer is null, this lets the analysis engine correctly discern that the pointer will in fact not be null and stop erroneous null pointer warnings.
This commit is contained in:
Robby Ciliberto 2024-07-21 18:42:46 -04:00
parent 28898b026e
commit 8700f483e5
No known key found for this signature in database
GPG key ID: 48E980D4A3B07141

View file

@ -111,7 +111,7 @@ typedef struct Cpu_Capabilities {
#define alignat(x) __attribute__((aligned(x)))
#define COMPILER_HAS_MEMCPY_INTRINSICS 1
inline void
inline void __attribute__((noreturn))
crash() {
__builtin_trap();
volatile int *a = 0;