diff options
author | Thomas Wouters <thomas@python.org> | 2006-02-01 21:32:04 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-02-01 21:32:04 (GMT) |
commit | 553489ab1db7990998aae3bffc0a1e20f5dc51af (patch) | |
tree | 92c02a3706458b75bcd741b140a4f199bba82e93 /Objects/longobject.c | |
parent | 548148810bfb4f44450a93f98912a5eee07d4303 (diff) | |
download | cpython-553489ab1db7990998aae3bffc0a1e20f5dc51af.zip cpython-553489ab1db7990998aae3bffc0a1e20f5dc51af.tar.gz cpython-553489ab1db7990998aae3bffc0a1e20f5dc51af.tar.bz2 |
As discussed on python-dev, silence three gcc-4.0.x warnings, using assert()
to protect against actual uninitialized usage.
Objects/longobject.c: In function ‘PyLong_AsDouble’:
Objects/longobject.c:655: warning: ‘e’ may be used uninitialized in this function
Objects/longobject.c: In function ‘long_true_divide’:
Objects/longobject.c:2263: warning: ‘aexp’ may be used uninitialized in this function
Objects/longobject.c:2263: warning: ‘bexp’ may be used uninitialized in this function
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 6f98d44..32f7958 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -652,7 +652,7 @@ _PyLong_AsScaledDouble(PyObject *vv, int *exponent) double PyLong_AsDouble(PyObject *vv) { - int e; + int e = -1; double x; if (vv == NULL || !PyLong_Check(vv)) { @@ -662,6 +662,9 @@ PyLong_AsDouble(PyObject *vv) x = _PyLong_AsScaledDouble(vv, &e); if (x == -1.0 && PyErr_Occurred()) return -1.0; + /* 'e' initialized to -1 to silence gcc-4.0.x, but it should be + set correctly after a successful _PyLong_AsScaledDouble() call */ + assert(e >= 0); if (e > INT_MAX / SHIFT) goto overflow; errno = 0; @@ -2260,7 +2263,7 @@ long_true_divide(PyObject *v, PyObject *w) { PyLongObject *a, *b; double ad, bd; - int aexp, bexp, failed; + int failed, aexp = -1, bexp = -1; CONVERT_BINOP(v, w, &a, &b); ad = _PyLong_AsScaledDouble((PyObject *)a, &aexp); @@ -2270,6 +2273,10 @@ long_true_divide(PyObject *v, PyObject *w) Py_DECREF(b); if (failed) return NULL; + /* 'aexp' and 'bexp' were initialized to -1 to silence gcc-4.0.x, + but should really be set correctly after sucessful calls to + _PyLong_AsScaledDouble() */ + assert(aexp >= 0 && bexp >= 0); if (bd == 0.0) { PyErr_SetString(PyExc_ZeroDivisionError, |