3 ms·
Addressing those doesn't create bugs, and I'm not sure why it would. Anything that changes behaviour could create bugs. Here is an example signed bar = s
by adrianratnapala 10y ago
Addressing those doesn't create bugs, and I'm not sure why it would.
Anything that changes behaviour could create bugs. Here is an example
signed bar = something_possibly_negative();
if(some_case) {
bar = calc_returning_unsigned_where_MSB_is_an_error_flag();
if(bar < 0)
return ERROR;
}
// now bar is valid, whether negative or positive.
This is a correct - if dodgy - way to test the MSB. But now if you get a warning about the signed integer not having the full range of the unsigned integer you might "fix" it by changing the first line to
long long bar = something_possibly_negative();
Now the signed bar covers the full range of the unsigned calculation - including the garbage in the error case.
For more in this vein see: http://ithare.com/best-practices-vs-witch-hunts/ http://ithare.com/best-practices-vs-witch-hunts/