Undefined behavior in TCX code with Clang v18
Basic info
- Commit SHA: 0a8c81ba
- Platform: Windows and Linux
Bug description
The Clang v18 complier issues an error about undefined behavior in the RCcontextMapping_encode2_estimate_no_mem_s17_LCS() function.
Ways to reproduce
Compile the codec using clang v18 compiler with the usan option.
cmake -B cmake-build -G "Unix Makefiles" -DCLANG=usan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
and then run e.g.
./IVAS_cod -mc 5_1 384000 48 scripts/testv/spectral_test_6ch_48kHz.wav bit
This results in the following error:
E /mnt/c/Work/IVAS/ivas-pc-codec/ivas-codec/lib_enc/ACcontextMapping_enc.c:1340:17: runtime error: implicit conversion from type 'int' of value 279314 (32-bit, signed) to type 'uint16_t' (aka 'unsigned short') changed the value to 17170 (16-bit, unsigned)