Skip to content

Commit

Permalink
refactor: Avoid GCC false positive error
Browse files Browse the repository at this point in the history
This avoids an overly agressive GCC false positive warning:

error: ‘tmp’ may be used uninitialized [-Werror=maybe-uninitialized]
  • Loading branch information
MarcoFalke committed Jan 20, 2025
1 parent fa40807 commit fa8ade3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/test/fuzz/float.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2021 The Bitcoin Core developers
// Copyright (c) 2020-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand All @@ -11,14 +11,15 @@
#include <cassert>
#include <cmath>
#include <limits>
#include <optional>

FUZZ_TARGET(float)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());

{
const double d{[&] {
double tmp;
std::optional<double> tmp;
CallOneOf(
fuzzed_data_provider,
// an actual number
Expand All @@ -42,7 +43,7 @@ FUZZ_TARGET(float)
}); },
// Anything from raw memory (also checks that DecodeDouble doesn't crash on any input)
[&] { tmp = DecodeDouble(fuzzed_data_provider.ConsumeIntegral<uint64_t>()); });
return tmp;
return *tmp;
}()};
(void)memusage::DynamicUsage(d);

Expand Down

0 comments on commit fa8ade3

Please sign in to comment.