Skip to content

Commit fa8ade3

Browse files
author
MarcoFalke
committed
refactor: Avoid GCC false positive error
This avoids an overly agressive GCC false positive warning: error: ‘tmp’ may be used uninitialized [-Werror=maybe-uninitialized]
1 parent fa40807 commit fa8ade3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/test/fuzz/float.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020-2021 The Bitcoin Core developers
1+
// Copyright (c) 2020-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -11,14 +11,15 @@
1111
#include <cassert>
1212
#include <cmath>
1313
#include <limits>
14+
#include <optional>
1415

1516
FUZZ_TARGET(float)
1617
{
1718
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
1819

1920
{
2021
const double d{[&] {
21-
double tmp;
22+
std::optional<double> tmp;
2223
CallOneOf(
2324
fuzzed_data_provider,
2425
// an actual number
@@ -42,7 +43,7 @@ FUZZ_TARGET(float)
4243
}); },
4344
// Anything from raw memory (also checks that DecodeDouble doesn't crash on any input)
4445
[&] { tmp = DecodeDouble(fuzzed_data_provider.ConsumeIntegral<uint64_t>()); });
45-
return tmp;
46+
return *tmp;
4647
}()};
4748
(void)memusage::DynamicUsage(d);
4849

0 commit comments

Comments
 (0)