diff --git a/hash.c b/hash.c
index 38440f4b96..b4b077fada 100644
--- a/hash.c
+++ b/hash.c
@@ -5656,9 +5656,10 @@ static void
keylist_delete(VALUE keys, VALUE key)
{
long keylen, elen;
+ long i;
const char *keyptr, *eptr;
RSTRING_GETMEM(key, keyptr, keylen);
- for (long i=0; i<RARRAY_LEN(keys); i++) {
+ for (i=0; i<RARRAY_LEN(keys); i++) {
VALUE e = RARRAY_AREF(keys, i);
RSTRING_GETMEM(e, eptr, elen);
if (elen != keylen) continue;