Commit a5d892bd authored by Sebastien Alaiwan's avatar Sebastien Alaiwan Committed by sebastien alaiwan
Browse files

Don't rely on signed-integer overflow to detect out-of-range values.

Signed-integer overflow is undefined behaviour in C.

Change-Id: Ib2d7f405adacc668264a5d77aba00ca85ecbb0f7
parent 1a02439f
......@@ -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;
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: "
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment