From 3a2f04ab3b3d4f36657b52205030d9a8297141ea Mon Sep 17 00:00:00 2001 From: William Katz Date: Sun, 6 Jun 2021 17:30:45 -0700 Subject: [PATCH] :bug: when pre_log_size == 0, illegal instruction would be generated --- main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index a2a72fc..7f85baf 100644 --- a/main.cpp +++ b/main.cpp @@ -22,9 +22,15 @@ void SaveSig(int s) int main(int argc, char **argv) { - // Static assertations for logging only (!max_log_size) - static_assert(!max_log_size || pre_log_size < max_log_size, "`max_log_size` must be larger than `pre_log_size`."); - static_assert(!max_log_size || !(max_log_size % pre_log_size), "`max_log_size` must be a multiple of `pre_log_size`."); + static_assert(pre_log_size <= max_log_size, "`max_log_size` must be larger than `pre_log_size`."); + if constexpr (max_log_size && pre_log_size) + { + if (max_log_size % pre_log_size) + { + std::cerr << "`max_log_size` must be a multiple of `pre_log_size`."; + return 0; + } + } if (argc != 4) {