How do I solve these warnings?
// midiNote is a double as it is used in floating point equation
// v is int because t
I believe this is a bug in VS2019
For instance this produces the warning
double test2(int n)
{
return 4.0 * (n - 1);
}
But this doesn't
int test2a(int n)
{
return 4 * (n - 1);
}
Yet, the risk of undefined behavior is much greater for the latter. Multiplying by 4 greatly increases the risk of UB since a far large set of n's will produce UB
Arguably, for a warning to be set that high virtually any arithmetic operation on ints would be warned.
This answer shows a way to disable this warning in VS 2019 in the code analysis rule set editor.
Warning C26454: Arithmetic overflow: '-' operation produces a negative unsigned result at compile time (io.5)