From 950a88c741dbf511bb94b8cbfccb1a77286ff40c Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Tue, 23 Feb 2021 22:08:27 -0800 Subject: [PATCH] bug: add __builtin_unreachable in BUG_ON_HANDLER This will surpress false gcc warnings like this: criu/stats.c:85:10: error: array subscript 4 is above array bounds of 'struct timing[2]' [-Werror=array-bounds] 85 | return &rstats->timings[t]; | ^~~~~~~~~~~~~~~~~~~ criu/stats.c:25:16: note: while referencing 'timings' 25 | struct timing timings[RESTORE_TIME_NS_STATS]; | ^~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Andrei Vagin --- include/common/bug.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/common/bug.h b/include/common/bug.h index 462291104..bacbf566b 100644 --- a/include/common/bug.h +++ b/include/common/bug.h @@ -24,6 +24,7 @@ pr_err("BUG at %s:%d\n", __FILE__, __LINE__); \ __raise(); \ *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ + __builtin_unreachable(); \ } \ } while (0) #else