I have the AddDataBlock function which is part of the implementation of the Whirlpool hash function.
CppCheck claims the following I changed the line numbers to match this comment:
Shifting 32-bit value by 520 bits is undefined behaviour. See condition at line 53.
line 55 -> Assuming that condition 'm_i32BufferBits==512' is not redundant
line 54 -> Assignment to 'm_i32BufferBits+=8-u8BufferRem'
line 53 -> Shift
Because u8BufferRem is an unsigned int of 8-bits and line 30 makes sure it can only have a value from 0 through 7, how can there possibly be a shift of 520 bits?!?
I have the AddDataBlock function which is part of the implementation of the Whirlpool hash function.
CppCheck claims the following I changed the line numbers to match this comment:
Shifting 32-bit value by 520 bits is undefined behaviour. See condition at line 53.
line 55 -> Assuming that condition 'm_i32BufferBits==512' is not redundant
line 54 -> Assignment to 'm_i32BufferBits+=8-u8BufferRem'
line 53 -> Shift
Because u8BufferRem is an unsigned int of 8-bits and line 30 makes sure it can only have a value from 0 through 7, how can there possibly be a shift of 520 bits?!?
I don't see it neither. Possibly it's a false positive. I can't reproduce with this code.
Can you try to reduce it? Try to remove various includes. And other functions. etc..
Here is a shorter version which doesn't make any sense anymore, but still gives the same error:
Standalone example:
Output:
Last edit: CHR 2022-01-25
I have created a ticket here: https://trac.cppcheck.net/ticket/10773