[issue1621] Do not assume signed integer overflow behavior

Martin v. Löwis report at bugs.python.org
Mon Jan 28 09:14:21 CET 2008


Martin v. Löwis added the comment:

> With Neal, I don't see what the warning in _csv is about. What condition
> is being turned into a constant? Is the compiler perhaps rearranging the
> code so as to insert "if (field[0] == '\0') goto XXX;" in front of the
> for-loop where XXX jumps into the middle of the condition in the
> if-statement immediately following the for-loop, and skipping that
> if-block when breaking of the loop later?

Indeed that's what happens. In the case of breaking the loop later,
the compiler can skip the if-block only if signed ints never overflow,
hence the warning.

Another way of silencing the warning is to test field[0]=='\0' in the
if-statement. This might also somewhat pessimize the code, but allows
the compiler to eliminate i altogether.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1621>
__________________________________


More information about the Python-bugs-list mailing list