EASTL
EASTL copied to clipboard
Incorrect behaviour of vector (and other) with switched off exceptions
struct Foo
{
Foo();
~Foo();
Foo(const Foo& a);
};
vector<Foo> foo;
foo.resize(1);
foo.resize(200);//this line will call operator = on never constructed Foo, instead of copy constructor
In the end, operator = destructor will be called from never constructed elements.
this happens, because uninitialized_move_ptr uses is_trivially_copy_assignable (which is true), rather than is_trivially_copyable, I guess.
It seems, that minimum possible fix is
--- a/prog/3rdPartyLibs/eastl/include/EASTL/memory.h
+++ b/prog/3rdPartyLibs/eastl/include/EASTL/memory.h
@@ -692,7 +692,7 @@ namespace eastl
template <typename InputIterator, typename ForwardIterator>
inline ForwardIterator uninitialized_move_impl(InputIterator first, InputIterator last, ForwardIterator dest, true_type)
{
- return eastl::copy(first, last, dest); // The copy() in turn will use memcpy for is_trivially_copy_assignable (e.g. POD) types.
+ return eastl::uninitialized_copy(first, last, dest); // The copy() in turn will use memcpy for is_trivially_copy_assignable (e.g. POD) types.
}
template <typename InputIterator, typename ForwardIterator>
which logically makes sense, since it should be uninitialized_copy. However, it will require is_trivial to perform, rather than is_trivially_copyable