]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
default_3way_compare(): When comparing the pointers, they must be cast
authorBarry Warsaw <barry@python.org>
Sat, 20 Jan 2001 06:08:10 +0000 (06:08 +0000)
committerBarry Warsaw <barry@python.org>
Sat, 20 Jan 2001 06:08:10 +0000 (06:08 +0000)
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.

Objects/object.c

index 44344f9b2c25f508323c2bf590f9fcd4e433a2d5..e2a019fdf7ce458e97ec4e508d729627c42ee109 100644 (file)
@@ -525,8 +525,8 @@ default_3way_compare(PyObject *v, PyObject *w)
 
        if (v->ob_type == w->ob_type) {
                /* same type: compare pointers */
-               void *vv = v;
-               void *ww = w;
+               Py_uintptr_t vv = (Py_uintptr_t)v;
+               Py_uintptr_t ww = (Py_uintptr_t)w;
                return (vv < ww) ? -1 : (vv > ww) ? 1 : 0;
        }