Fixed order of calling use_facet vs setbuf in basic_filebuf default constructor.

llvm-svn: 162571
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 45c03a8f8d45edd174d715f4245a7984f766e2eb
diff --git a/include/fstream b/include/fstream
index 4a9cb72..83731a1 100644
--- a/include/fstream
+++ b/include/fstream
@@ -261,12 +261,12 @@
       __owns_ib_(false),
       __always_noconv_(false)
 {
-    setbuf(0, 4096);
     if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
     {
         __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
         __always_noconv_ = __cv_->always_noconv();
     }
+    setbuf(0, 4096);
 }
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES