Message ID | 20180816193837.GI13845@redhat.com |
---|---|
State | New |
Headers | show |
Series | RFC: reduce likelihood of fully-dynamic-string throwing on move | expand |
--- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -3575,7 +3575,10 @@ _GLIBCXX_END_NAMESPACE_CXX11 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 __str._M_data(_S_empty_rep()._M_refdata()); #else - __str._M_data(_S_construct(size_type(), _CharT(), get_allocator())); + if (__str._M_is_leaked()) + __str._M_data(_S_construct(size_type(), _CharT(), get_allocator())); + else + (void) _M_rep()->_M_refcopy(); #endif }