Message270084
One common case where signed integer overflow has been assumed has been the wraparound/overflow checks like in http://bugs.python.org/issue27473
I propose that such commonly erroneous tasks such as overflow checks be implemented as common macros in CPython as getting them right is not quite easy (http://c-faq.com/misc/sd26.html); it would also make the C code more self-documenting.
Thus instead of writing
if (va.len > PY_SSIZE_T_MAX - vb.len) {
one would write something like
if (PY_SSIZE_T_SUM_OVERFLOWS(va.len, vb.len)) {
and the mere fact that such a macro *wasn't* used there would signal about possible problems with the comparison. |
|
Date |
User |
Action |
Args |
2016-07-10 13:05:57 | ztane | set | recipients:
+ ztane, gvanrossum, loewis, nnorwitz, gregory.p.smith, jcea, mark.dickinson, pitrou, vstinner, christian.heimes, alexandre.vassalotti, donmez, matejcik, jwilk, alex, dmalcolm, python-dev, deadshort, fweimer, Jeffrey.Walton |
2016-07-10 13:05:56 | ztane | set | messageid: <1468155956.8.0.0898850628094.issue1621@psf.upfronthosting.co.za> |
2016-07-10 13:05:56 | ztane | link | issue1621 messages |
2016-07-10 13:05:56 | ztane | create | |
|