From 8700f483e50e57da2616e2809d79a888706d32a0 Mon Sep 17 00:00:00 2001 From: Robby Ciliberto Date: Sun, 21 Jul 2024 18:42:46 -0400 Subject: [PATCH] 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. --- oogabooga/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oogabooga/cpu.c b/oogabooga/cpu.c index 9c3e3b0..a32c914 100644 --- a/oogabooga/cpu.c +++ b/oogabooga/cpu.c @@ -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;