diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic
index a8acb4e304a7add6285e323cedf7736e3d25eeb6..8443b5fa07d80d47be4c1227596c6b89c912a0e3 100644
--- a/innobase/include/rem0rec.ic
+++ b/innobase/include/rem0rec.ic
@@ -713,8 +713,9 @@ rec_offs_validate(
 		}
 	}
 	if (index) {
+		ulint max_n_fields;
 		ut_ad((ulint) index == offsets[2]);
-		ulint max_n_fields = ut_max(
+		max_n_fields = ut_max(
 				dict_index_get_n_fields(index),
 				dict_index_get_n_unique_in_tree(index) + 1);
 		if (comp && rec) {