The future of 32-bit Linux
The future of 32-bit Linux
Posted Dec 5, 2020 14:57 UTC (Sat) by khim (subscriber, #9252)In reply to: The future of 32-bit Linux by warrax
Parent article: The future of 32-bit Linux
Surprisingly enough no. It's not an UB to convert from signed to unsigned type and back. When number is representable in both — conversion is guaranteed to keep it's value, if not — it's implementation-defined behavior, not undefined behavior.
This being said it's not all peach and roses. Unsigned type is “dominant”, if you mix signed and unsigned in the same expression results can be surprising, e.g. “u > -1” is almost always true because -1 is interpreted as 0xFFFFFFFF.
But no, there are no problems with UB.
