Denis Vlasenko wrote:
I want sane compiler. One in which N-bit integer variables stay exactly N-bit. Without "magic" N+1 bit which is there "somethimes". a*2/2: If I say "multiply by 2 and _after that_ divide by 2, I meant that. Compiler can optimize it any way it wants, as long as result is the same as unoptimized one.
I am sure others will say this too, but the demand that optimization not affect behavior is entirely unrealistic and unreasonable. The whole point of making things undefined in C is to allow compilers the freedom to optimize. Now that does not mean that one should always take advantage (my position is that you want to be careful in taking advantage of undefined and make sure the gain is worth the surprise), but to say that you should NEVER take advantage of this would have terrible effects on the code.
Above: v is a signed entity. I expect (v < 0) to be equal to "most significant bit is set". It's not about standards. It's about sanity.
Well for sure I don't think you want minus zero to be less than plus zero on a 1's complement machine, that would not be sane. Things are never simple!
-- vda