59 for ( i = 0; i < CZ * CY * CX; i++ ) {
-> 60 buf[i] = ( unsigned short ) (i * 0.01);
61 }
Also note:
#define CZ 142
#define CY 245
#define CX 210
Thus the loop runs 7 305 900 times, which even after dividing by 100 gives numbers too big to fit in an unsigned 16 bit number and UBSan warns:
41: (/Users/builder/external/libminc-clang-dbg-x86_64-static/testdir/minc2-hyper-test-2+0x100004e36): runtime error: value 65536 is outside the range of representable values of type 'unsigned short'
Does the buffer contents matter much? If I divide by 1000 instead the test passed and the warning is gone.
UBSan finds only one test failure (nice!):
The test "minc2-hyper-test-2" has this loop:
Also note:
Thus the loop runs 7 305 900 times, which even after dividing by 100 gives numbers too big to fit in an unsigned 16 bit number and UBSan warns:
Does the buffer contents matter much? If I divide by 1000 instead the test passed and the warning is gone.