Laszlo Ersek <ler...@redhat.com> writes: > I accept this is a defensible, maybe even reasonable choice to make in > the QEMU project. On the other hand, I personally cannot stop hating > shifting negative values (any direction) -- indeed, the *original* code > from <https://github.com/madler/zlib/pull/112> makes me barf too. > > Therefore, > > Grudgingly-reviewed-by: Laszlo Ersek <ler...@redhat.com> > > (I realize the flag for the pointer wraparound has been separated; this > is strictly about shifts.)
What's so abhorrent about shifting negative values? I know machines with signed integer representations other than twos complement exist, as do machines that can't do both logical and arithmetic shifts. Mostly inside computer museums, though. C was standardized at a time when keeping the language sufficiently loose to permit efficient implementation on these oddball machines made a lot more sense than it does now. Making it undefined behavior went too far, though. Implementation-defined or unspecified behavior would have sufficed. Learn to stop worrying and love the signed shifts :)