diff --git a/src/json.hpp b/src/json.hpp
index 02d28613..79df1f78 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -5752,7 +5752,7 @@ class basic_json
             }
 
             /// increment operator (needed for range-based for)
-            iterator_wrapper_internal operator++()
+            iterator_wrapper_internal& operator++()
             {
                 ++anchor;
                 ++array_index;
diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c
index ae4a41bb..585aa205 100644
--- a/src/json.hpp.re2c
+++ b/src/json.hpp.re2c
@@ -5752,7 +5752,7 @@ class basic_json
             }
 
             /// increment operator (needed for range-based for)
-            iterator_wrapper_internal operator++()
+            iterator_wrapper_internal& operator++()
             {
                 ++anchor;
                 ++array_index;
diff --git a/test/unit.cpp b/test/unit.cpp
index 63c1e6f3..f50fead8 100644
--- a/test/unit.cpp
+++ b/test/unit.cpp
@@ -7554,8 +7554,8 @@ TEST_CASE("iterator_wrapper")
         json j_object = {{"key1", 1}, {"key2", 2}};
         for (auto it : json::iterator_wrapper(j_object))
         {
-            CHECK((it.first == "key1" or it.first == "key2"));
-            CHECK((it.key() == "key1" or it.key() == "key2"));
+            CHECK((it.first == json("key1") or it.first == json("key2")));
+            CHECK((it.key() == json("key1") or it.key() == json("key2")));
             CHECK(it.key() == it.first);
 
             CHECK((it.second == json(1) or it.second == json(2)));