Fix incorrect exception handling behavior in the uninitialized algorithms

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283941 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-10-11 21:13:44 +00:00
parent 9d97e2bc3f
commit 05577c82e1
6 changed files with 130 additions and 79 deletions

View File

@@ -27,7 +27,7 @@ struct Counted {
static void reset() { count = constructed = 0; }
explicit Counted() { ++count; ++constructed; }
Counted(Counted const&) { assert(false); }
~Counted() { --count; }
~Counted() { assert(count > 0); --count; }
friend void operator&(Counted) = delete;
};
int Counted::count = 0;
@@ -47,7 +47,7 @@ struct ThrowsCounted {
++count;
}
ThrowsCounted(ThrowsCounted const&) { assert(false); }
~ThrowsCounted() { --count; }
~ThrowsCounted() { assert(count > 0); --count; }
friend void operator&(ThrowsCounted) = delete;
};
int ThrowsCounted::count = 0;
@@ -66,10 +66,8 @@ void test_ctor_throws()
std::uninitialized_value_construct(It(p), It(p+N));
assert(false);
} catch (...) {}
assert(ThrowsCounted::count == 3);
assert(ThrowsCounted::constructed == 4); // forth construction throws
std::destroy(p, p+3);
assert(ThrowsCounted::count == 0);
assert(ThrowsCounted::constructed == 4); // forth construction throws
#endif
}