mirror of git://gcc.gnu.org/git/gcc.git
Add missing return to uninitialized_default_construct_n
* include/bits/stl_uninitialized.h (__uninitialized_default_novalue_n_1<true>): Add missing return. * testsuite/20_util/specialized_algorithms/memory_management_tools/ 1.cc: Check return values of uninitialized_xxx_n algorithms. From-SVN: r241033
This commit is contained in:
parent
40571365a0
commit
08a53a2eda
|
|
@ -1,5 +1,10 @@
|
||||||
2016-10-12 Jonathan Wakely <jwakely@redhat.com>
|
2016-10-12 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/stl_uninitialized.h
|
||||||
|
(__uninitialized_default_novalue_n_1<true>): Add missing return.
|
||||||
|
* testsuite/20_util/specialized_algorithms/memory_management_tools/
|
||||||
|
1.cc: Check return values of uninitialized_xxx_n algorithms.
|
||||||
|
|
||||||
* libsupc++/nested_exception.h (throw_with_nested): Remove return.
|
* libsupc++/nested_exception.h (throw_with_nested): Remove return.
|
||||||
|
|
||||||
* doc/xml/manual/intro.xml: Document LWG 2442 status.
|
* doc/xml/manual/intro.xml: Document LWG 2442 status.
|
||||||
|
|
|
||||||
|
|
@ -705,8 +705,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
template<typename _ForwardIterator, typename _Size>
|
template<typename _ForwardIterator, typename _Size>
|
||||||
static _ForwardIterator
|
static _ForwardIterator
|
||||||
__uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
|
__uninit_default_novalue_n(_ForwardIterator __first, _Size __n)
|
||||||
{
|
{ return std::next(__first, __n); }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// __uninitialized_default_novalue
|
// __uninitialized_default_novalue
|
||||||
|
|
|
||||||
|
|
@ -74,15 +74,17 @@ void test02()
|
||||||
void test03()
|
void test03()
|
||||||
{
|
{
|
||||||
char test_data[] = "123456";
|
char test_data[] = "123456";
|
||||||
std::uninitialized_default_construct_n(std::begin(test_data), 6);
|
auto end = std::uninitialized_default_construct_n(std::begin(test_data), 6);
|
||||||
VERIFY(std::string(test_data) == "123456");
|
VERIFY(std::string(test_data) == "123456");
|
||||||
|
VERIFY( end == test_data + 6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test04()
|
void test04()
|
||||||
{
|
{
|
||||||
char test_data[] = "123456";
|
char test_data[] = "123456";
|
||||||
std::uninitialized_value_construct_n(std::begin(test_data), 6);
|
auto end = std::uninitialized_value_construct_n(std::begin(test_data), 5);
|
||||||
VERIFY(std::string(test_data, 6) == std::string("\0\0\0\0\0\0", 6));
|
VERIFY(std::string(test_data, 6) == std::string("\0\0\0\0\0" "6", 6));
|
||||||
|
VERIFY( end == test_data + 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test05()
|
void test05()
|
||||||
|
|
@ -112,8 +114,9 @@ void test07()
|
||||||
del_count = 0;
|
del_count = 0;
|
||||||
DelCount* x = (DelCount*)malloc(sizeof(DelCount)*10);
|
DelCount* x = (DelCount*)malloc(sizeof(DelCount)*10);
|
||||||
for (int i = 0; i < 10; ++i) new (x+i) DelCount;
|
for (int i = 0; i < 10; ++i) new (x+i) DelCount;
|
||||||
std::destroy_n(x, 10);
|
auto end = std::destroy_n(x, 10);
|
||||||
VERIFY(del_count == 10);
|
VERIFY(del_count == 10);
|
||||||
|
VERIFY( end == x + 10 );
|
||||||
del_count = 0;
|
del_count = 0;
|
||||||
free(x);
|
free(x);
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +130,8 @@ void test08()
|
||||||
std::uninitialized_move(source.begin(), source.end(), target);
|
std::uninitialized_move(source.begin(), source.end(), target);
|
||||||
for (const auto& x : source) VERIFY(!x);
|
for (const auto& x : source) VERIFY(!x);
|
||||||
for (int i = 0; i < 10; ++i) VERIFY(bool(*(target+i)));
|
for (int i = 0; i < 10; ++i) VERIFY(bool(*(target+i)));
|
||||||
std::destroy_n(target, 10);
|
auto end = std::destroy_n(target, 10);
|
||||||
|
VERIFY( end == target + 10 );
|
||||||
free(target);
|
free(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,10 +141,13 @@ void test09()
|
||||||
for (int i = 0; i < 10; ++i) source.push_back(std::make_unique<int>(i));
|
for (int i = 0; i < 10; ++i) source.push_back(std::make_unique<int>(i));
|
||||||
std::unique_ptr<int>* target =
|
std::unique_ptr<int>* target =
|
||||||
(std::unique_ptr<int>*)malloc(sizeof(std::unique_ptr<int>)*10);
|
(std::unique_ptr<int>*)malloc(sizeof(std::unique_ptr<int>)*10);
|
||||||
std::uninitialized_move_n(source.begin(), 10, target);
|
auto end = std::uninitialized_move_n(source.begin(), 10, target);
|
||||||
|
VERIFY( end.first == source.begin() + 10 );
|
||||||
|
VERIFY( end.second == target + 10 );
|
||||||
for (const auto& x : source) VERIFY(!x);
|
for (const auto& x : source) VERIFY(!x);
|
||||||
for (int i = 0; i < 10; ++i) VERIFY(bool(*(target+i)));
|
for (int i = 0; i < 10; ++i) VERIFY(bool(*(target+i)));
|
||||||
std::destroy_n(target, 10);
|
auto end2 = std::destroy_n(target, 10);
|
||||||
|
VERIFY( end2 == target + 10 );
|
||||||
free(target);
|
free(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,7 +163,8 @@ void test11()
|
||||||
{
|
{
|
||||||
char* x = (char*)malloc(sizeof(char)*10);
|
char* x = (char*)malloc(sizeof(char)*10);
|
||||||
for (int i = 0; i < 10; ++i) new (x+i) char;
|
for (int i = 0; i < 10; ++i) new (x+i) char;
|
||||||
std::destroy_n(x, 10);
|
auto end = std::destroy_n(x, 10);
|
||||||
|
VERIFY( end == x + 10 );
|
||||||
free(x);
|
free(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -285,10 +293,12 @@ void test19()
|
||||||
{
|
{
|
||||||
char test_source[] = "123456";
|
char test_source[] = "123456";
|
||||||
char test_target[] = "000000";
|
char test_target[] = "000000";
|
||||||
std::uninitialized_move_n(std::begin(test_source),
|
auto end = std::uninitialized_move_n(std::begin(test_source),
|
||||||
6,
|
6,
|
||||||
test_target);
|
test_target);
|
||||||
VERIFY(std::string(test_target) == "123456");
|
VERIFY(std::string(test_target) == "123456");
|
||||||
|
VERIFY( end.first == test_source + 6 );
|
||||||
|
VERIFY( end.second == test_target + 6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue