Don't rely on signed-integer overflow to detect out-of-range values.
Signed-integer overflow is undefined behaviour in C. Change-Id: Ib2d7f405adacc668264a5d77aba00ca85ecbb0f7
This commit is contained in:
Родитель
1a02439fa0
Коммит
a5d892bdb8
|
@ -95,7 +95,7 @@ static INLINE int32_t half_btf(int32_t w0, int32_t in0, int32_t w1, int32_t in1,
|
|||
int32_t result_32 = w0 * in0 + w1 * in1;
|
||||
#if CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
int64_t result_64 = (int64_t)w0 * (int64_t)in0 + (int64_t)w1 * (int64_t)in1;
|
||||
if (result_32 != result_64) {
|
||||
if (result_64 < INT32_MIN || result_64 > INT32_MAX) {
|
||||
printf("%s %d overflow result_32: %d result_64: %" PRId64
|
||||
" w0: %d in0: %d w1: %d in1: "
|
||||
"%d\n",
|
||||
|
|
Загрузка…
Ссылка в новой задаче