[boost/f21] Fix boost::shared_ptr<T>::operator[] for non-array T's

Petr Machata pmachata at fedoraproject.org
Wed Nov 12 20:51:18 UTC 2014


commit cfbd80b49d33213d0f1459744784f92d038aab49
Author: Petr Machata <pmachata at redhat.com>
Date:   Wed Nov 12 19:36:48 2014 +0100

    Fix boost::shared_ptr<T>::operator[] for non-array T's

 boost-1.54.0-smart_ptr-shared_ptr_at.patch |   88 ++++++++++++++++++++++++++++
 boost.spec                                 |   10 +++-
 2 files changed, 97 insertions(+), 1 deletions(-)
---
diff --git a/boost-1.54.0-smart_ptr-shared_ptr_at.patch b/boost-1.54.0-smart_ptr-shared_ptr_at.patch
new file mode 100644
index 0000000..675e13d
--- /dev/null
+++ b/boost-1.54.0-smart_ptr-shared_ptr_at.patch
@@ -0,0 +1,88 @@
+From f65c57d9d2a4f535e36c96b7f563574634e46b02 Mon Sep 17 00:00:00 2001
+From: Peter Dimov <pdimov at pdimov.com>
+Date: Wed, 12 Nov 2014 19:04:29 +0200
+Subject: [PATCH] Fix explicit instantiation regression
+
+---
+ include/boost/smart_ptr/shared_ptr.hpp |  2 +-
+ test/Jamfile.v2                        |  2 ++
+ test/array_fail_array_access.cpp       |  6 +++++-
+ test/sp_explicit_inst_test.cpp         | 23 +++++++++++++++++++++++
+ 4 files changed, 31 insertions(+), 2 deletions(-)
+ create mode 100644 test/sp_explicit_inst_test.cpp
+
+diff --git a/include/boost/smart_ptr/shared_ptr.hpp b/include/boost/smart_ptr/shared_ptr.hpp
+index 82ece8b..8be92ab 100644
+--- a/boost/smart_ptr/shared_ptr.hpp
++++ b/boost/smart_ptr/shared_ptr.hpp
+@@ -655,7 +655,7 @@ public:
+         BOOST_ASSERT( px != 0 );
+         BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) );
+ 
+-        return px[ i ];
++        return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] );
+     }
+ 
+     element_type * get() const BOOST_NOEXCEPT
+diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
+index 027367c..0b51eee 100644
+--- a/libs/smart_ptr/test/Jamfile.v2
++++ b/libs/smart_ptr/test/Jamfile.v2
+@@ -153,5 +153,7 @@ import testing ;
+           [ run allocate_shared_array_throws_test.cpp ]
+           [ run allocate_shared_array_esft_test.cpp ]
+           [ run allocate_shared_array_args_test.cpp ]
++
++          [ compile sp_explicit_inst_test.cpp ]
+         ;
+ }
+diff --git a/test/array_fail_array_access.cpp b/test/array_fail_array_access.cpp
+index abfacbe..4f4e3f8 100644
+--- a/libs/smart_ptr/test/array_fail_array_access.cpp
++++ b/libs/smart_ptr/test/array_fail_array_access.cpp
+@@ -12,8 +12,12 @@ struct X
+ {
+ };
+ 
++template<class T> void f( T & /*t*/ )
++{
++}
++
+ int main()
+ {
+     boost::shared_ptr<X> px( new X );
+-    px[ 0 ];
++    f( px[ 0 ] );
+ }
+diff --git a/test/sp_explicit_inst_test.cpp b/test/sp_explicit_inst_test.cpp
+new file mode 100644
+index 0000000..d8de782
+--- /dev/null
++++ b/libs/smart_ptr/test/sp_explicit_inst_test.cpp
+@@ -0,0 +1,23 @@
++//
++// Explicit instantiations are reported to exist in user code
++//
++// Copyright (c) 2014 Peter Dimov
++//
++// Distributed under the Boost Software License, Version 1.0.
++// See accompanying file LICENSE_1_0.txt or copy at
++// http://www.boost.org/LICENSE_1_0.txt
++//
++
++#include <boost/shared_ptr.hpp>
++
++template class boost::shared_ptr< int >;
++
++struct X
++{
++};
++
++template class boost::shared_ptr< X >;
++
++int main()
++{
++}
+-- 
+2.1.0
+
diff --git a/boost.spec b/boost.spec
index a9c628c..46e5698 100644
--- a/boost.spec
+++ b/boost.spec
@@ -36,7 +36,7 @@ Name: boost
 Summary: The free peer-reviewed portable C++ source libraries
 Version: 1.55.0
 %define version_enc 1_55_0
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: Boost and MIT and Python
 
 %define toplev_dirname %{name}_%{version_enc}
@@ -157,6 +157,9 @@ Patch56: boost-1.55.0-xpressive-unused_typedefs.patch
 # Fixed upstream on Aug 20 05:11:14 2013.
 Patch57: boost-1.55.0-spirit-unused_typedefs.patch
 
+# https://bugzilla.redhat.com/show_bug.cgi?id=1159960
+Patch58: boost-1.54.0-smart_ptr-shared_ptr_at.patch
+
 %bcond_with tests
 %bcond_with docs_generated
 
@@ -643,6 +646,7 @@ a number of significant features and is now developed independently
 %patch55 -p1
 %patch56 -p1
 %patch57 -p1
+%patch58 -p1
 
 # At least python2_version needs to be a macro so that it's visible in
 # %%install as well.
@@ -1245,6 +1249,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/bjam.1*
 
 %changelog
+* Wed Nov 12 2014 Petr Machata <pmachata at redhat.com> - 1.55.0-4
+- Fix boost::shared_ptr<T>::operator[], which was ill-formed for
+  non-array T's.  (boost-1.54.0-smart_ptr-shared_ptr_at.patch)
+
 * Fri Aug 15 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.55.0-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
 


More information about the scm-commits mailing list