4 ms·
Converting a signed negative number to unsigned is UB.
by titzer 4y ago
Converting a signed negative number to unsigned is UB.
- anonymoushn 4y agoCan you provide a citation? I have above quoted the part of the standard that defines the value of the result of the conversion. It looks like C++20 updated this so that conversion both ways is defined in a way that preserves two's complement bit-patterns, which you can see here: https://eel.is/c++draft/conv#integral-3 https://eel.is/c++draft/conv#integral-3