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:
Disservin
2025-03-29 11:55:55 +01:00
parent 4a869f41c6
commit aafc732bcb
+19 -1
View File
@@ -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]);