diff --git a/doc/developer-notes.md b/doc/developer-notes.md --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -17,6 +17,8 @@ - No space after function names; one space after `if`, `for` and `while`. - Always add braces for block statements (e.g. `if`, `for`, `while`). - `++i` is preferred over `i++`. + - `static_assert` is preferred over `assert` where possible. + Generally; compile-time checking is preferred over run-time checking. - Use CamelCase for functions/methods, and lowerCamelCase for variables. - GLOBAL_CONSTANTS should use UPPER_SNAKE_CASE. - namespaces should use lower_snake_case. diff --git a/src/arith_uint256.h b/src/arith_uint256.h --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -258,7 +258,8 @@ unsigned int bits() const; uint64_t GetLow64() const { - assert(WIDTH >= 2); + static_assert(WIDTH >= 2, "Assertion WIDTH >= 2 failed (WIDTH = BITS / " + "32). BITS is a template parameter."); return pn[0] | (uint64_t)pn[1] << 32; } };