23 ms·
> Do you know that in MSVC uint16_t(50000) + uin16_t(50000) == -1794967296? Not only is that insane code and both my compiler and static analysis go for my thr
by bun_terminator 3y ago
> Do you know that in MSVC uint16_t(50000) + uin16_t(50000) == -1794967296?
Not only is that insane code and both my compiler and static analysis go for my throat, it's also not true. I think the argument is supposed to be about unsigned integer overflow, but the numbers don't add up. The big negative number wraps to 63744. And the sum (100K) wraps to 34464.
- dzaima 3y agoIt seems the intent was for "*" to be used instead of "+". At which point it's actually undefined behavior even though the operands are unsigned!
- bun_terminator 3y agothat makes more sense!