diff Objects/object.c @ 14051:fee0f402eccb legacy-trunk

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.
author Barry Warsaw <barry@python.org>
date Fri, 18 Aug 2000 05:01:19 +0000
parents ed369f0aa32b
children 41eb755e4ed1
line wrap: on
line diff
--- a/Objects/object.c	Fri Aug 18 05:00:03 2000 +0000
+++ b/Objects/object.c	Fri Aug 18 05:01:19 2000 +0000
@@ -371,12 +371,14 @@
 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 @@
 		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