Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!cs.utexas.edu!nthropy!andy From: andy@nthropy.UUCP (Andy Lowe) Newsgroups: comp.windows.x Subject: right shifting negative numbers considered harmful Message-ID: <9101231726.AA05052@nth.com> Date: 23 Jan 91 17:26:28 GMT Lines: 30 Posted-Date: Wed, 23 Jan 91 11:26:28 CST To: comp-windows-x@cs.utexas.edu Dear X server hackers, My copy of the ANSI C spec says that when right shifting E1 >> E2, "If E1 has a signed type, whether the right shift is logical (fill with zeros) or arithmetic (fill with a copy of the sign bit) is implementation-defined." (section 3.3.7) Consider the following fragment of code from the MIARCOCTANTSHIFT macro in mizerarc.h ... d = b - (a >> 1) - d + (k3 >> 3); \ ... this is called out from the cfb arc drawing routines. Note that variable a can be negative. I have the misfortune to be running on an architecture without an arithmetic right shift instruction, and so my compiler has exercised it's "implementation-defined" option. In the interests of portability, can someone arrange to fix this apparent ANSI non-compliance in the standard distribution? I'm using R4. Perhaps it is already fixed in R5. Does anybody know? many thanks. Andy Lowe andy@nth.com