diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc
index 14854cfa4acab184c743ec08e3035f0707f01163..93bda92c9185a0466ca78336b95d2894c948f982 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -133,7 +133,7 @@ grpc::string PackageToModule(const grpc::string& name) {
   grpc::string result;
   result.reserve(name.size());
 
-  for (int i = 0; i < name.size(); i++) {
+  for (grpc::string::size_type i = 0; i < name.size(); i++) {
     if (name[i] == '_') {
       next_upper = true;
     } else {