Remove node from a container before destroying it. Thanks to Alexander Potapenko for pointing this out.

llvm-svn: 206024
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: ec959d5f46b6d54be51000cf1eb7707b9b9488a5
diff --git a/include/__tree b/include/__tree
index acf8759..8e5447a 100644
--- a/include/__tree
+++ b/include/__tree
@@ -1980,9 +1980,9 @@
         __begin_node() = __r.__ptr_;
     --size();
     __node_allocator& __na = __node_alloc();
-    __node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
     __tree_remove(__end_node()->__left_,
                   static_cast<__node_base_pointer>(__np));
+    __node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
     __node_traits::deallocate(__na, __np, 1);
     return __r;
 }