Skip to content

Use two-argument static_assert in CRYPTOPP_COMPILE_ASSERT - #1359

Open
Coralesoft wants to merge 1 commit into
weidai11:masterfrom
Coralesoft:fix/compile-assert-cxx11
Open

Use two-argument static_assert in CRYPTOPP_COMPILE_ASSERT#1359
Coralesoft wants to merge 1 commit into
weidai11:masterfrom
Coralesoft:fix/compile-assert-cxx11

Conversation

@Coralesoft

Copy link
Copy Markdown
Contributor

Summary

CRYPTOPP_COMPILE_ASSERT expanded to static_assert(expr), which is the single-argument C++17 form. This can warn under -Wc++17-extensions when code is compiled as C++14.

Using static_assert(expr, #expr) keeps the macro compatible with C++11 and C++14. The stringified expression also gives a useful message when the assert fails.

What changed

  • Updated CRYPTOPP_COMPILE_ASSERT in misc.h to use static_assert(expr, #expr).

CRYPTOPP_COMPILE_ASSERT expanded to static_assert(expr), which is a C++17
form. This can warn under -Wc++17-extensions when code is compiled as C++14.

Use static_assert(expr, #expr) instead. The two-argument form is C++11 and
works with the standards the library supports. The stringified expression is
also useful in compile-error messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant