Index: stl_tempbuf.h =================================================================== --- stl_tempbuf.h (revision 151122) +++ stl_tempbuf.h (working copy) @@ -182,6 +182,7 @@ : _M_original_len(std::distance(__first, __last)), _M_len(0), _M_buffer(0) { + pointer __cur(0); __try { std::pair __p(std::get_temporary_buffer< @@ -189,10 +190,31 @@ _M_buffer = __p.first; _M_len = __p.second; if (!__is_pod(_Tp) && _M_len > 0) - std::uninitialized_fill_n(_M_buffer, _M_len, *__first); + { + // The following code fills an uninitalised buffer of + // value_type, where value_type does not have to be copy or + // default constructable. + // + // We do this by move constructing an already existing object + // of type value_type (*__first) to the beginning of the buffer, + // then move constructing each item in the buffer from the previous + // one. This moves our original object along the buffer, leaving a + // list of constructed, moved-from objects. + // Finally at the end we move the value back to *__first. + ::new(static_cast(_M_buffer)) + value_type(_GLIBCXX_MOVE(*__first)); + for(__cur = _M_buffer + 1; __cur != _M_buffer + _M_len; ++__cur) + { + ::new(static_cast(__cur)) + value_type(_GLIBCXX_MOVE(*(__cur - 1))); + } + *__first = _GLIBCXX_MOVE(*(_M_buffer + _M_len - 1)); + } } __catch(...) { + if(__cur) + _Destroy(_M_buffer, __cur); std::return_temporary_buffer(_M_buffer); _M_buffer = 0; _M_len = 0;