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 <rep...@bugs.python.org>
<http://bugs.python.org/issue25845>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to