Skip to content

Commit

Permalink
Clarify disabling of static assert checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nurupo committed Dec 5, 2023
1 parent 65b3375 commit 63fb294
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion other/analysis/run-clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 63fb294

Please sign in to comment.