4 ms·
I tried to compile it, and I also couldn't find any other flag, than -Wconversion, that would detect this: for(i = 0; i < length; i++) sum += a[i] * b[i];
by asgfoi 11y ago
I tried to compile it, and I also couldn't find any other flag, than -Wconversion, that would detect this:
for(i = 0; i < length; i++) sum += a[i] * b[i];
^
I managed to hide the error if return values, which are double, are replaced with float_t. I believe in that case the bug stays in, but -Wconversion doesn't detect it.
Of course the warning can always be silenced by doing something like:
for(i = 0; i < length; i++) sum += ( double )( a[i] * b[i] );
and adding a misleading comment about the explicit cast.
- scatters 11y agoThe interesting thing about changing return types is that you can alter the return type of spectral_contrast to float_t without affecting behavior, since float is promoted to double for argument passing (it's passed and returned in the xmm registers).