On Fri, Jun 03, 2005 at 06:25:27PM +0200, Florian Weimer wrote: > There's also a fair amount of code whih relies on -1 == > (int)0xFFFFFFFF.
While that is not portable, -(1U) is portably all-ones, even on 36 bit one's complement machines or other oddball architectures, since unsigned types are required to obey the rules of modulo arithmetic. Switching to unsigned is usually the best thing to do if you want to assume that overflow wraps. Nevertheless, I frequently design software that is intentionally not portable to all possible ISO C/C++ platforms (typically assuming either ILP32 or LP64 with IEEE floating point arithmetic, with tests to determine the behavior of certain unspecified operations like the behavior of % with negative arguments). However, the nonportable constructs are only used when there is no portable construct that is equally efficient. OK, I know, this is getting off-topic.