[New-bugs-announce] [issue25845] _ctypes\cfield.c identical subexpressions in Z_set
Alexander Riccio
report at bugs.python.org
Fri Dec 11 23:50:49 EST 2015
New submission from Alexander Riccio:
I found this while writing up a separate bug (CPython doesn't use static analysis!).
In _ctypes/cfield.c, Z_set has a bug of some sort:
if (PyLong_Check(value) || PyLong_Check(value)) {
See: https://hg.python.org/cpython/file/tip/Modules/_ctypes/cfield.c#l1378
...which has been there for at least 5 years: https://hg.python.org/cpython/rev/cab14be0ada1
I'm not sure what the original programmer meant - it's been around forever & I don't know what was there before it - but PyLong_Check(value) is evaluated twice. Which doesn't really make sense.
Compiling with /analyze found this quite easily:
c:\pythondev\repo\modules\_ctypes\cfield.c(1378): warning C6287: Redundant code: the left and right sub-expressions are identical.
There's a similar issue in P_set, at line 1486.
----------
components: ctypes
messages: 256256
nosy: Alexander Riccio, amaury.forgeotdarc, belopolsky, meador.inge
priority: normal
severity: normal
status: open
title: _ctypes\cfield.c identical subexpressions in Z_set
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25845>
_______________________________________
More information about the New-bugs-announce
mailing list