diff --git a/folly/Format-inl.h b/folly/Format-inl.h
index 5331bbba199038caed2cae4e9104ebcb40d5fe1e..fb756197f3b89aa549b6a3ce8599cba5b7401da0 100644
--- a/folly/Format-inl.h
+++ b/folly/Format-inl.h
@@ -199,8 +199,6 @@ template <class Derived, bool containerMode, class... Args>
 template <class Output>
 void BaseFormatter<Derived, containerMode, Args...>::appendOutput(Output& out)
     const {
-  auto p = str_.begin();
-  auto end = str_.end();
 
   // Copy raw string (without format specifiers) to output;
   // not as simple as we'd like, as we still need to translate "}}" to "}"
@@ -225,6 +223,9 @@ void BaseFormatter<Derived, containerMode, Args...>::appendOutput(Output& out)
     }
   };
 
+  auto p = str_.begin();
+  auto end = str_.end();
+
   int nextArg = 0;
   bool hasDefaultArgIndex = false;
   bool hasExplicitArgIndex = false;