volk
volk copied to clipboard
Undefined Behaviour in volk_8u_x4_conv_k7_r2_8u
UBSAN reports undefined behaviour in this code:
https://github.com/gnuradio/volk/blob/42f57cd67506e7fb6a7795af3948b803de0085f4/kernels/volk/volk_8u_x4_conv_k7_r2_8u.h#L112-L113
Here w
is an unsigned int[2]
, and the s * (sizeof(decision_t) / sizeof(unsigned int))
calculation intentionally reaches outside the bounds of the array to access the s
th element of the outer decision_t
array d
.
It looks like this hack became necessary because sizeof(decision_t)
is 8, and yet it is marked as being 16-byte aligned; because of this, accessing d[1]
(or any other odd offset) fails due to misalignment. I suspect that the 16-byte alignment of decision_t
is incorrect or unnecessary.