Date: Sat, 6 Nov 2021 10:40:58 -0700 From: Alistair Crooks <a...@pkgsrc.org> Message-ID: <can5gjxq4tzrtxnm8g4+9x78rnzfxoqgkszatpyqztv2w-mu...@mail.gmail.com>
| The author of the software made a conscious decision | to make the variable unsigned, sincr the length | would never be less than zero. | | The author then made a default definition for the | lower bound of the length, and made it 0. Both of those are readonable. | I find it ironic that an overbearing, | over-eager compiler takes these, | decides that the condition could never be true, I have not looked at the code, but this suggests that with the decisions above, the code is then going and checking if the impossible is true. "since the length would never be less than 0" the data type cannot store valuse less than 0, so testing if such a value is less than 0 is stupid, and proobabky indicates a logic error. | and so a cast to an integer type is now needed | to shut up the overeager compiler, I agree with your implication, doing that would be insane, and potentially break correct code, if the var was ever > INT_MAX and <= UINT_MAX then the test with the cast would indicate an invalid length, which, perhaps, it is not. The right thing to do is to delete the meaningless test. If you're concerned that the assumptions/decisions above might one day be altered, then instead of deleting the test, put it in a #if MIN_VALUE != 0 #endif block instead. So: | Nevertheless, I'll make the changes you suggest don't do that. kre