From 2fb1b29d371f1536d730852681f90ab6757acd8a Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 24 May 2019 14:00:26 +0100 Subject: [PATCH] Fix broken shared_ptr test * testsuite/20_util/shared_ptr/cons/alias-rval.cc: Fix test. * testsuite/20_util/shared_ptr/cons/alias.cc: Remove unused function. From-SVN: r271603 --- libstdc++-v3/ChangeLog | 5 +++++ .../20_util/shared_ptr/cons/alias-rval.cc | 20 ++++++++++--------- .../20_util/shared_ptr/cons/alias.cc | 2 -- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 90043c55f1a..0a83bd3252c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2019-05-24 Jonathan Wakely + + * testsuite/20_util/shared_ptr/cons/alias-rval.cc: Fix test. + * testsuite/20_util/shared_ptr/cons/alias.cc: Remove unused function. + 2019-05-23 Jonathan Wakely * testsuite/20_util/function_objects/invoke/1.cc: Move C++17-specific diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc index 205587cde66..f0b0d9cf9ff 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc @@ -37,8 +37,6 @@ struct B : A A a; }; -void deletefunc(A* p) { delete p; } - // 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] // Aliasing constructors @@ -63,29 +61,33 @@ test01() void test02() { - std::shared_ptr a(new A); + A* ptr = new A; + ptr->i = 100; + std::shared_ptr a(ptr); std::shared_ptr i1(std::move(a), &a->i); VERIFY( i1.use_count() == 1 ); - VERIFY( i1 != nullptr ); + VERIFY( *i1 == 100 ); VERIFY( a.use_count() == 0 ); VERIFY( a == nullptr ); std::shared_ptr i2(i1); VERIFY( i2.use_count() == 2 ); - VERIFY( i2.get() == &a->i ); + VERIFY( i2.get() == &ptr->i ); } void test03() { std::shared_ptr b1(new B); + b1->i = 100; + b1->a.i = 200; std::shared_ptr b2(b1); std::shared_ptr a1(std::move(b1), b1.get()); - std::shared_ptr a2(b2, &b2->a); + std::shared_ptr a2(std::move(b2), &b2->a); + VERIFY( a1.use_count() == 2 ); VERIFY( a2.use_count() == 2 ); - VERIFY( a1 != nullptr ); - VERIFY( a2 != nullptr ); - VERIFY( a1 != a2 ); + VERIFY( a1->i == 100 ); + VERIFY( a2->i == 200 ); VERIFY( b1.use_count() == 0 ); VERIFY( b2.use_count() == 0 ); VERIFY( b1 == nullptr ); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc index 134a05894a2..8dbb7af638c 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc @@ -36,8 +36,6 @@ struct B : A A a; }; -void deletefunc(A* p) { delete p; } - // 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] // Aliasing constructors -- 2.30.2