From: Lisandro Dalcin Date: Thu, 11 Mar 2010 16:42:02 +0000 (-0300) Subject: fix signed/unsigned comparison in buffer access code X-Git-Tag: 0.13.beta0~319^2~2^2~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=032c1738f1fd58278e58f21f642e0c75d35a1558;p=cython.git fix signed/unsigned comparison in buffer access code --- diff --git a/Cython/Compiler/Buffer.py b/Cython/Compiler/Buffer.py index bf6eef8b..955ee205 100644 --- a/Cython/Compiler/Buffer.py +++ b/Cython/Compiler/Buffer.py @@ -368,8 +368,12 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, code.putln("%s = %d;" % (tmp_cname, dim)) code.put("} else ") # check bounds in positive direction + if signed != 0: + cast = "" + else: + cast = "(size_t)" code.putln("if (%s) %s = %d;" % ( - code.unlikely("%s >= %s" % (cname, shape.cname)), + code.unlikely("%s >= %s%s" % (cname, cast, shape.cname)), tmp_cname, dim)) code.globalstate.use_utility_code(raise_indexerror_code) code.putln("if (%s) {" % code.unlikely("%s != -1" % tmp_cname))