From: Christopher Dykes Date: Fri, 17 Jun 2016 01:12:47 +0000 (-0700) Subject: Fix infinite recursion in sorted_vector_{set|map}::insert(const value_type&) X-Git-Tag: 2016.07.26~135 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b57cfc00ce7e280fb89a421fc2402cfcc14337b7;p=folly.git Fix infinite recursion in sorted_vector_{set|map}::insert(const value_type&) Summary: We were calling ourself, which MSVC correctly identified: ``` warning C4717: 'folly::sorted_vector_set,std::allocator,void>::insert': recursive on all control paths, function will cause runtime stack overflow ``` Just add an explicit `std::move` in to solve the problem. Reviewed By: yfeldblum Differential Revision: D3447922 fbshipit-source-id: 803f79510b3dbfeea32a9629238448f69f5b78dc --- diff --git a/folly/sorted_vector_types.h b/folly/sorted_vector_types.h index b9354b10..e9f77d3a 100644 --- a/folly/sorted_vector_types.h +++ b/folly/sorted_vector_types.h @@ -244,7 +244,7 @@ public: size_type capacity() const { return m_.cont_.capacity(); } std::pair insert(const value_type& value) { - return insert(value_type(value)); + return insert(std::move(value_type(value))); } std::pair insert(value_type&& value) { @@ -257,7 +257,7 @@ public: } iterator insert(iterator hint, const value_type& value) { - return insert(hint, value_type(value)); + return insert(hint, std::move(value_type(value))); } iterator insert(iterator hint, value_type&& value) { @@ -488,7 +488,7 @@ public: size_type capacity() const { return m_.cont_.capacity(); } std::pair insert(const value_type& value) { - return insert(value_type(value)); + return insert(std::move(value_type(value))); } std::pair insert(value_type&& value) { @@ -501,7 +501,7 @@ public: } iterator insert(iterator hint, const value_type& value) { - return insert(hint, value_type(value)); + return insert(hint, std::move(value_type(value))); } iterator insert(iterator hint, value_type&& value) {