diff options
author | Barry Warsaw <barry@python.org> | 2000-08-18 05:01:19 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-08-18 05:01:19 (GMT) |
commit | 9d23a4eb037abc4d6026dda09ffda39eb8701a1e (patch) | |
tree | 72d7b01211c70300b626e417c28737ce270445f5 /Objects/object.c | |
parent | 67c1a04bbbad20a6a66aa32d35fe41baf2660a51 (diff) | |
download | cpython-9d23a4eb037abc4d6026dda09ffda39eb8701a1e.zip cpython-9d23a4eb037abc4d6026dda09ffda39eb8701a1e.tar.gz cpython-9d23a4eb037abc4d6026dda09ffda39eb8701a1e.tar.bz2 |
make_pair(): When comparing the pointers, they must be cast to integer
types (i.e. Py_uintptr_t, our spelling of C9X's uintptr_t). ANSI
specifies that pointer compares other than == and != to non-related
structures are undefined. This quiets an Insure portability warning.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c index 99fea99..f61a1dd 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -371,12 +371,14 @@ static PyObject * make_pair(PyObject *v, PyObject *w) { PyObject *pair; + Py_uintptr_t iv = (Py_uintptr_t)v; + Py_uintptr_t iw = (Py_uintptr_t)w; pair = PyTuple_New(2); if (pair == NULL) { return NULL; } - if (v <= w) { + if (iv <= iw) { PyTuple_SET_ITEM(pair, 0, PyLong_FromVoidPtr((void *)v)); PyTuple_SET_ITEM(pair, 1, PyLong_FromVoidPtr((void *)w)); } else { @@ -487,7 +489,9 @@ PyObject_Compare(PyObject *v, PyObject *w) return strcmp(vname, wname); } if (vtp->tp_compare == NULL) { - return (v < w) ? -1 : 1; + Py_uintptr_t iv = (Py_uintptr_t)v; + Py_uintptr_t iw = (Py_uintptr_t)w; + return (iv < iw) ? -1 : 1; } _PyCompareState_nesting++; if (_PyCompareState_nesting > NESTING_LIMIT |