Cleanup: BLI: add assertion for uninitialized boolean in IndexMask.from_predicate

Not properly initialized booleans cause problems due to the branchless increment.

Pull Request: https://projects.blender.org/blender/blender/pulls/115338
This commit is contained in:
Iliya Katueshenock 2023-11-24 10:30:18 +01:00 committed by Jacques Lucke
parent cbe0cf0bb0
commit 86fb922f54
1 changed files with 3 additions and 0 deletions

View File

@ -851,6 +851,9 @@ inline IndexMask IndexMask::from_predicate(const IndexMask &universe,
const int64_t global_index = int64_t(local_index) + offset;
const bool condition = predicate(global_index);
*r_current = local_index;
/* This expects the boolean to be either 0 or 1 which is generally the case but may not
* be if the values are uninitialized. */
BLI_assert(ELEM(int8_t(condition), 0, 1));
/* Branchless conditional increment. */
r_current += condition;
}