diff --git a/include/flatbuffers/stl_emulation.h b/include/flatbuffers/stl_emulation.h
index 4ec7bc18fef5271da3103c89c02f062cbc7c27c1..3cb3c76d6d6d8fbe6735427a2c02aaab2bcb383a 100644
--- a/include/flatbuffers/stl_emulation.h
+++ b/include/flatbuffers/stl_emulation.h
@@ -38,6 +38,10 @@ namespace flatbuffers {
 
 // Retrieve ::back() from a string in a way that is compatible with pre C++11
 // STLs (e.g stlport).
+inline char& string_back(std::string &value) {
+  return value[value.length() - 1];
+}
+
 inline char string_back(const std::string &value) {
   return value[value.length() - 1];
 }
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index 86fbf40bb4ca4cca8d9e50d7213711f6217f2ae1..a9ac01c7617ce43c3bf6a0389b19985d9f5bcc60 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -216,7 +216,7 @@ inline std::string ConCatPathFileName(const std::string &path,
                                       const std::string &filename) {
   std::string filepath = path;
   if (filepath.length()) {
-    char filepath_last_character = string_back(filepath);
+    char &filepath_last_character = string_back(filepath);
     if (filepath_last_character == kPathSeparatorWindows) {
       filepath_last_character = kPathSeparator;
     } else if (filepath_last_character != kPathSeparator) {