I have read the related questions to this Lint warning about the suspicious truncation, but here it is a purely C case.
The following line is where the Warning #647
pops up:
pCont->sig -= (signed int64_t)((sub2 << 8)/pCont->freq + 1);
where pCont->sig
is also 64 bit signed (type signed int64_t
), and both sub2
and freq
are 32 bit unsigned. All this is compiled with armcc.
Already tried, without success, to cast the 1
to unsigned 32 bit, but the problem persists.
Any idea on what I might try, or what is going wrong here?
From this reference about the warning
For example:
(long) (n << 8)
might elicit this message if n is unsigned int, whereas
(long) n << 8
would not. In the first case, the shift is done at int precision and the high order 8 bits are lost even though there is a subsequent conversion to a type that might hold all the bits. In the second case, the shifted bits are retained.
This seems to fit your case exactly and also show you how to fix it.