fix signed/unsigned comparison in buffer access code
authorLisandro Dalcin <dalcinl@gmail.com>
Thu, 11 Mar 2010 16:42:02 +0000 (13:42 -0300)
committerLisandro Dalcin <dalcinl@gmail.com>
Thu, 11 Mar 2010 16:42:02 +0000 (13:42 -0300)
Cython/Compiler/Buffer.py

index bf6eef8b9083c5459492918881bb0a74bd560345..955ee2058df85cb9e5631687b78de5c3cf1c5a88 100644 (file)
@@ -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))