From 032c1738f1fd58278e58f21f642e0c75d35a1558 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Thu, 11 Mar 2010 13:42:02 -0300 Subject: [PATCH] fix signed/unsigned comparison in buffer access code --- Cython/Compiler/Buffer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)) -- 2.26.2