diff options
author | fanquake <fanquake@gmail.com> | 2023-12-08 12:05:30 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-12-08 12:10:16 +0000 |
commit | 3e691258d8789a4a89cce42e7e71b130491594d7 (patch) | |
tree | 35c0aaa4a84dbb05738cd5443d8d940052b72d22 /src/test | |
parent | 03042fb6bb35135566f47892b7fd15b34ca19cef (diff) | |
parent | fa6e50d6c79633e22ad4cfc75f56aaa40112ecbb (diff) |
Merge bitcoin/bitcoin#28349: build: Require C++20 compiler
fa6e50d6c79633e22ad4cfc75f56aaa40112ecbb fuzz: Use C++20 starts_with in rpc.cpp (MarcoFalke)
faa48388bca06df1ca7ab92461b76a6720481e45 Revert "tracepoints: Disables `-Wgnu-zero-variadic-macro-arguments` to compile without warnings" (MarcoFalke)
fae3b77a87f4d799aca5907335a9dcbab3a51db6 refactor: Drop unused _Pragma to ignore -Wgnu-zero-variadic-macro-arguments (MarcoFalke)
fa02fc0a86c410f907de4fee91dd045547ea4b6e refactor: modernize-use-default-member-init for bit-fields (C++20) (MarcoFalke)
fa67f096bdea9db59dd20c470c9e32f3dac5be94 build: Require C++20 compiler (MarcoFalke)
Pull request description:
C++20 allows to write safer code, because it allows to enforce more stuff at compile time (`constinit`, `conteval`, `constexpr`, `std::span`, ...).
Also, it allows to write less verbose and easier to understand code (C++ 20 Concepts).
See https://github.com/bitcoin/bitcoin/issues/23363 and https://en.cppreference.com/w/cpp/compiler_support#cpp20
With g++-10 (https://github.com/bitcoin/bitcoin/pull/28348) and clang-13 (https://github.com/bitcoin/bitcoin/pull/28210), there is broad support for almost all features of C++20.
It should be fine to require a C++20 compiler for Bitcoin Core 27.0 in 2024 (next year), not the soon upcoming 26.0 next month.
This pull request includes three small cleanups to make use of C++20 features. If any issues are detected before or after merge, this should be easy to revert. If no issues arise, it should be fine to make use of more involved C++20 features later on.
ACKs for top commit:
fanquake:
ACK fa6e50d6c79633e22ad4cfc75f56aaa40112ecbb
Tree-SHA512: 244d79bfb0b750a4bdd713f40573b9ca33816fb84b6c84a58f027b9d7d4bb0cc4f18642959e4cf3d094808a69e5b8a327ca8521d7c0c08af27dacb5da3e78e71
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/fuzz.h | 4 | ||||
-rw-r--r-- | src/test/fuzz/rpc.cpp | 4 |
2 files changed, 1 insertions, 7 deletions
diff --git a/src/test/fuzz/fuzz.h b/src/test/fuzz/fuzz.h index 1f0fa5527a..ca74d53de7 100644 --- a/src/test/fuzz/fuzz.h +++ b/src/test/fuzz/fuzz.h @@ -33,11 +33,7 @@ struct FuzzTargetOptions { void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, FuzzTargetOptions opts); -#if defined(__clang__) -#define FUZZ_TARGET(...) _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"") DETAIL_FUZZ(__VA_ARGS__) _Pragma("clang diagnostic pop") -#else #define FUZZ_TARGET(...) DETAIL_FUZZ(__VA_ARGS__) -#endif #define DETAIL_FUZZ(name, ...) \ void name##_fuzz_target(FuzzBufferType); \ diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index 2189dc0067..2325bf0941 100644 --- a/src/test/fuzz/rpc.cpp +++ b/src/test/fuzz/rpc.cpp @@ -380,9 +380,7 @@ FUZZ_TARGET(rpc, .init = initialize_rpc) rpc_testing_setup->CallRPC(rpc_command, arguments); } catch (const UniValue& json_rpc_error) { const std::string error_msg{json_rpc_error.find_value("message").get_str()}; - // Once c++20 is allowed, starts_with can be used. - // if (error_msg.starts_with("Internal bug detected")) { - if (0 == error_msg.rfind("Internal bug detected", 0)) { + if (error_msg.starts_with("Internal bug detected")) { // Only allow the intentional internal bug assert(error_msg.find("trigger_internal_bug") != std::string::npos); } |