[issue1621] Do not assume signed integer overflow behavior
Neal Norwitz
report at bugs.python.org
Mon Jan 28 03:41:06 CET 2008
Neal Norwitz added the comment:
I just added -Wstrict-overflow to the code in sysmodule.c
(sys_getframe) and tried with gcc 4.2.1. It doesn't warn. I wonder
if 4.3 is more picky or warns when it shouldn't?
Unless if I changed the code so it doesn't work:
typedef struct {int ref;} PyObject;
typedef struct { PyObject* f_back; } PyFrameObject;
int PyArg_ParseTuple(PyObject*, const char*, int*);
PyObject *
sys_getframe(PyFrameObject *f, PyObject *self, PyObject *args)
{
int depth = -1;
if (!PyArg_ParseTuple(args, "|i:_getframe", &depth))
return 0;
while (depth > 0 && f != 0) {
f = (PyFrameObject*)f->f_back;
--depth;
}
return (PyObject*)f;
}
Compiled with:
gcc-4.2.1-glibc-2.3.2/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc
-Wstrict-overflow -c xx.c
produced no warnings. This is not a stock gcc 4.2.1, so that could
also be an issue. Did I run it correctly. Is there anything else I
need to do? If you run the code above with gcc 4.3, does it produce a
warning?
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1621>
__________________________________
More information about the Python-bugs-list
mailing list