3 ms·
The argument starts here: > I really don’t like this asymmetry – it leads to annoying edge cases in all sort of integer APIs. And gets to here: > Third, you’
by jmull 4y ago
The argument starts here:
> I really don’t like this asymmetry – it leads to annoying edge cases in all sort of integer APIs.
And gets to here:
> Third, you’re getting an unused bit pattern 0b1'0000000, the old INT_MIN, which you can interpret however you like.
This isn't solving the original problem. If you don't like annoying edge cases in all sorts of integer APIs, it's worse.
edit: I can add: the article goes on to suggest that
"old INT_MIN" should be called INT_NAN and "let’s just say arithmetic on INT_NAN is undefined behavior". So now what's the result of a + b? Undefined behavior! a * b? Undefined behavior! The general result of any function taking an integer or returning one is undefined behavior!
- turminal 4y agoArithmetic on INT_MIN is already undefined behaviour.
- renox 4y ago? No! INT_MIN +1 is 'implementation defined behaviour' but that's a very different thing.
- kzrdude 4y agoIn C, with int a, b then a + b is already potential UB. Just depends on the values of the variables. It is remarkable to note this.. but not new! :)