[Python-Dev] Drop support for ones' complement machines?

Mark Dickinson dickinsm at gmail.com
Tue Dec 1 15:02:17 CET 2009

On Tue, Dec 1, 2009 at 1:46 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> Mark Dickinson wrote:
>> Question:  should the CPython source compile cleanly and work
>> correctly on (mostly ancient or hypothetical) machines that use
>> ones' complement or sign-and-magnitude to represent signed integers?
> I think that's the wrong question to ask. What you really meant to ask
> (IIUC) is this: Should CPython be allowed to invoke behavior that is
> declared undefined by the C standard, but has a clear meaning when
> assuming two's complement?

No, the original question really was the question that I meant to ask.  :)

I absolutely agree that CPython shouldn't invoke undefined behaviour,
precisely because of the risk of gcc (or some other compiler)
optimizing based on the assumption that undefined behaviour never
happens.  This is why I opened issue 7406.

So my question, and the listed assumptions, are about implementation-
defined behaviour, not undefined behaviour.  For the 3 assumptions listed,
gcc obeys all those assumptions (see section 4.5 of the GCC manual).


Personally I can't think of any good reason not to make these assumptions.


More information about the Python-Dev mailing list