From bd2de7ac591d7704b79304089ad1fb57e085da8b Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Thu, 2 May 2024 21:52:46 +0100
Subject: [PATCH] refactor, test: Always initialize pointer
This change fixes MSVC warning C4703.
See: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4703
All `DisableSpecificWarnings` dropped from `test_bitcoin.vcxproj` as all
remained are inherited from `common.init.vcxproj`.
---
build_msvc/test_bitcoin/test_bitcoin.vcxproj | 5 -----
src/test/validation_chainstate_tests.cpp | 7 ++++---
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/build_msvc/test_bitcoin/test_bitcoin.vcxproj b/build_msvc/test_bitcoin/test_bitcoin.vcxproj
index 0ae3819e50..b5aa58057f 100644
--- a/build_msvc/test_bitcoin/test_bitcoin.vcxproj
+++ b/build_msvc/test_bitcoin/test_bitcoin.vcxproj
@@ -59,11 +59,6 @@
{18430fef-6b61-4c53-b396-718e02850f1b}
-
-
- 4018;4244;4267;4703;4715;4805
-
-
There was an error executing the JSON test header generation task.
diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp
index fe2d2ba592..1c02066047 100644
--- a/src/test/validation_chainstate_tests.cpp
+++ b/src/test/validation_chainstate_tests.cpp
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
#include
#include
@@ -102,14 +103,14 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 2);
- Chainstate& background_cs{*[&] {
+ Chainstate& background_cs{*Assert([&]() -> Chainstate* {
for (Chainstate* cs : chainman.GetAll()) {
if (cs != &chainman.ActiveChainstate()) {
return cs;
}
}
- assert(false);
- }()};
+ return nullptr;
+ }())};
// Append the first block to the background chain.
BlockValidationState state;