aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-05-13 17:42:18 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2015-05-13 17:42:18 +0100
commit098aac94ef8927e4bd24fc59919e9163057688fa (patch)
treecebeabdc23452f12716aa0864ea56906dcc360f7 /libstdc++-v3
parentb7dce216c7aabe73aae567e6565f44676246a518 (diff)
downloadgcc-098aac94ef8927e4bd24fc59919e9163057688fa.zip
gcc-098aac94ef8927e4bd24fc59919e9163057688fa.tar.gz
gcc-098aac94ef8927e4bd24fc59919e9163057688fa.tar.bz2
shared_ptr_base.h (__shared_count(unique_ptr&&)): Check for nullptr (LWG 2415).
* include/bits/shared_ptr_base.h (__shared_count(unique_ptr&&)): Check for nullptr (LWG 2415). * testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc: Test construction from empty unique_ptr. * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust dg-error. * testsuite/20_util/shared_ptr/cons/void_neg.cc: Likewise. From-SVN: r223170
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h5
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc16
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc2
5 files changed, 28 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 965cdcc..b9a0ad7 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,12 @@
2015-05-13 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/shared_ptr_base.h (__shared_count(unique_ptr&&)): Check
+ for nullptr (LWG 2415).
+ * testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc: Test
+ construction from empty unique_ptr.
+ * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust dg-error.
+ * testsuite/20_util/shared_ptr/cons/void_neg.cc: Likewise.
+
* include/bits/stl_raw_storage_iter.h (raw_storage_iterator::base()):
Define (LWG 2454).
* testsuite/20_util/raw_storage_iterator/base.cc: New.
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 8c3af12..081df87 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -632,6 +632,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
explicit
__shared_count(std::unique_ptr<_Tp, _Del>&& __r) : _M_pi(0)
{
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2415. Inconsistency between unique_ptr and shared_ptr
+ if (__r.get() == nullptr)
+ return;
+
using _Ptr = typename unique_ptr<_Tp, _Del>::pointer;
using _Del2 = typename conditional<is_reference<_Del>::value,
reference_wrapper<typename remove_reference<_Del>::type>,
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc
index 97cc139..6255522 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc
@@ -32,7 +32,7 @@ void test01()
{
X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 886 }
+ // { dg-error "incomplete" "" { target *-*-* } 891 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 307 }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc
index 67bf577..e010977 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc
@@ -34,7 +34,7 @@ int D::count = 0;
// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
// Construction from unique_ptr
-int
+void
test01()
{
bool test __attribute__((unused)) = true;
@@ -47,13 +47,25 @@ test01()
VERIFY( sp.use_count() == 1 );
}
VERIFY( D::count == 1 );
+}
- return 0;
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ D::count = 0;
+ std::unique_ptr<A, D> up;
+ {
+ std::shared_ptr<A> sp = std::move(up);
+ }
+ VERIFY( D::count == 0 ); // LWG 2415
}
int
main()
{
test01();
+ test02();
return 0;
}
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc
index 2afcd8b..3f6c4ae 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc
@@ -25,5 +25,5 @@
void test01()
{
std::shared_ptr<void> p((void*)nullptr); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 885 }
+ // { dg-error "incomplete" "" { target *-*-* } 890 }
}