Cleanup: quiet array-bounds warning in GCC 12.2

This commit is contained in:
Campbell Barton 2023-01-16 14:05:49 +11:00
parent 2467becade
commit cc5fefffe6
1 changed files with 7 additions and 4 deletions

View File

@ -388,18 +388,21 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
ED_armature_ebone_to_mat3(ebone, mat);
copy_v3_v3(vec, mat[2]);
}
else { /* Axis */
BLI_assert(type <= 5);
else if (type < 6) { /* NOTE: always true, check to quiet GCC12.2 `-Warray-bounds`. */
/* Axis */
if (type < 3) {
vec[type] = 1.0f;
}
else {
/* Use casting to quiet -Warray-bounds warning in gcc. */
vec[(int)type - 2] = -1.0f;
vec[type - 2] = -1.0f;
}
mul_m3_v3(imat, vec);
normalize_v3(vec);
}
else {
/* The previous block should handle all remaining cases. */
BLI_assert_unreachable();
}
if (axis_flip) {
negate_v3(vec);