diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index d34850b16e39fd5c3db4f58e46766a77c4139cec..b9d1f74ec12f55574caa9e773d52dc31769dd73f 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -68,7 +68,8 @@ template<> inline std::string NumToString<double>(double t) {
   auto p = s.find_last_not_of('0');
   if (p != std::string::npos) {
     s.resize(p + 1);  // Strip trailing zeroes.
-    if (s.back() == '.') s.pop_back();  // Strip '.' if a whole number.
+    if (s.back() == '.')
+      s.erase(s.size() - 1, 1);  // Strip '.' if a whole number.
   }
   return s;
 }