mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Silence "may be used uninitialized" GCC warning
Helps gcc silence the warning about ``` warning: 'added' may be used uninitialized [-Wmaybe-uninitialized] const IndexType offsetA0 = TransformedFeatureDimensions * added[0]; ``` closes https://github.com/official-stockfish/Stockfish/pull/5950 No functional change
This commit is contained in:
@@ -25,13 +25,25 @@
|
||||
#include "../bitboard.h"
|
||||
#include "../position.h"
|
||||
#include "../types.h"
|
||||
#include "nnue_architecture.h"
|
||||
#include "network.h"
|
||||
#include "nnue_architecture.h"
|
||||
#include "nnue_common.h"
|
||||
#include "nnue_feature_transformer.h"
|
||||
|
||||
namespace Stockfish::Eval::NNUE {
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#define sf_assume(cond) \
|
||||
do \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
__builtin_unreachable(); \
|
||||
} while (0)
|
||||
#else
|
||||
// do nothing for other compilers
|
||||
#define sf_assume(cond)
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
template<Color Perspective,
|
||||
@@ -245,6 +257,12 @@ void update_accumulator_incremental(
|
||||
else
|
||||
assert(removed.size() <= added.size());
|
||||
|
||||
// Workaround compiler warning for uninitialized variables, replicated on
|
||||
// profile builds on windows with gcc 14.2.0.
|
||||
// TODO remove once unneeded
|
||||
sf_assume(added.size() == 1 || added.size() == 2);
|
||||
sf_assume(removed.size() == 1 || removed.size() == 2);
|
||||
|
||||
#ifdef VECTOR
|
||||
auto* accIn =
|
||||
reinterpret_cast<const vec_t*>(&(computed.*accPtr).accumulation[Perspective][0]);
|
||||
|
||||
Reference in New Issue
Block a user