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:
parent
cbe0cf0bb0
commit
86fb922f54
|
@ -851,6 +851,9 @@ inline IndexMask IndexMask::from_predicate(const IndexMask &universe,
|
||||||
const int64_t global_index = int64_t(local_index) + offset;
|
const int64_t global_index = int64_t(local_index) + offset;
|
||||||
const bool condition = predicate(global_index);
|
const bool condition = predicate(global_index);
|
||||||
*r_current = local_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. */
|
/* Branchless conditional increment. */
|
||||||
r_current += condition;
|
r_current += condition;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue