From 63fb2941caf0d4822ca3e37ebc7ba439e7c476b9 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Tue, 5 Dec 2023 06:48:15 -0500 Subject: [PATCH] Clarify disabling of static assert checks --- other/analysis/run-clang-tidy | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/other/analysis/run-clang-tidy b/other/analysis/run-clang-tidy index 1fa49759..d1fcae1a 100755 --- a/other/analysis/run-clang-tidy +++ b/other/analysis/run-clang-tidy @@ -60,7 +60,23 @@ CHECKS="$CHECKS,-readability-redundant-control-flow" CHECKS="$CHECKS,-bugprone-narrowing-conversions" CHECKS="$CHECKS,-cppcoreguidelines-narrowing-conversions" -# TODO(iphydf): Probably fix this in tox-bootstrapd.c. +# Mistakenly thinks that +# const int a = 0, b = 1; +# assert(a < b); +# is a constant expression in C (it is in C++ though, which is probably why it's +# mistaken), suggesting to replace 'assert()' with 'static_assert()' in cases +# where that won't work. +# +# There are ways to make 'static_assert()' work, but they are rather annoying -- +# they are somewhat ugly, hurting the readability, and some are error-prone: +# +# - Turning 'a' and 'b' into enum constants would make it work, but this falls +# apart if the enum types are compared against non-enums down the line +# error: enumerated and non-enumerated type in conditional expression [-Werror=extra] +# +# - Turning 'a' and 'b' into pre-processor macros is the only option left, but +# #defines and #undefs in the middle of a function hurt the readability and +# are less idiomatic than simply using 'const int'. CHECKS="$CHECKS,-cert-dcl03-c" CHECKS="$CHECKS,-hicpp-static-assert" CHECKS="$CHECKS,-misc-static-assert"