Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61718 - trunk/libs/ptr_container/test
From: dgregor_at_[hidden]
Date: 2010-04-30 20:13:04


Author: dgregor
Date: 2010-04-30 20:13:03 EDT (Fri, 30 Apr 2010)
New Revision: 61718
URL: http://svn.boost.org/trac/boost/changeset/61718

Log:
At several places in the ptr_container tests, we have the following pattern:

void f(const std::auto_ptr<int> &); void g() {

f(std::auto_ptr<int>(new int(5)));

}

This is code is ill-formed in C++98/03, because the compiler is
required to check there there exits a copy constructor that would be
able to make a copy of the auto_ptr before binding it to a reference,
even if that copy won't actually be made. Not all compilers diagnose
this error, but Clang and EDG in strict mode do diagnose the problem.

Fixes #4174.

Text files modified:
   trunk/libs/ptr_container/test/associative_test_data.hpp | 5 +++--
   trunk/libs/ptr_container/test/ptr_set.cpp | 3 ++-
   trunk/libs/ptr_container/test/ptr_unordered_set.cpp | 3 ++-
   trunk/libs/ptr_container/test/sequence_test_data.hpp | 5 +++--
   4 files changed, 10 insertions(+), 6 deletions(-)

Modified: trunk/libs/ptr_container/test/associative_test_data.hpp
==============================================================================
--- trunk/libs/ptr_container/test/associative_test_data.hpp (original)
+++ trunk/libs/ptr_container/test/associative_test_data.hpp 2010-04-30 20:13:03 EDT (Fri, 30 Apr 2010)
@@ -102,7 +102,8 @@
     c.insert( c.end(), t );
     c.insert( c.end(), std::auto_ptr<T>( new T ) );
     c.insert( new T );
- c.insert( std::auto_ptr<T>( new T ) );
+ std::auto_ptr<T> ap( new T );
+ c.insert( ap );
     c3.insert( c.begin(), c.end() );
     c.erase( c.begin() );
     c3.erase( c3.begin(), c3.end() );
@@ -129,7 +130,7 @@
              
     c.insert( c.end(), new T );
     typename C::auto_type ptr2 = c.release( c.begin() );
- std::auto_ptr<C> ap = c.release();
+ std::auto_ptr<C> ap2 = c.release();
     c = c2.clone();
     BOOST_MESSAGE( "finished release/clone test" );
 

Modified: trunk/libs/ptr_container/test/ptr_set.cpp
==============================================================================
--- trunk/libs/ptr_container/test/ptr_set.cpp (original)
+++ trunk/libs/ptr_container/test/ptr_set.cpp 2010-04-30 20:13:03 EDT (Fri, 30 Apr 2010)
@@ -84,7 +84,8 @@
 
     BOOST_CHECK_THROW( set.insert( 0 ), bad_ptr_container_operation );
     set.insert( new int(0) );
- set.insert( std::auto_ptr<int>( new int(1) ) );
+ std::auto_ptr<int> ap( new int(1) );
+ set.insert( ap );
     BOOST_CHECK_THROW( (set.replace(set.begin(), 0 )), bad_ptr_container_operation );
     BOOST_CHECK_THROW( (set.replace(set.begin(), std::auto_ptr<int>(0) )), bad_ptr_container_operation );
 

Modified: trunk/libs/ptr_container/test/ptr_unordered_set.cpp
==============================================================================
--- trunk/libs/ptr_container/test/ptr_unordered_set.cpp (original)
+++ trunk/libs/ptr_container/test/ptr_unordered_set.cpp 2010-04-30 20:13:03 EDT (Fri, 30 Apr 2010)
@@ -106,7 +106,8 @@
 
     BOOST_CHECK_THROW( set.insert( 0 ), bad_ptr_container_operation );
     set.insert( new int(0) );
- set.insert( std::auto_ptr<int>( new int(1) ) );
+ std::auto_ptr<int> ap( new int(1) );
+ set.insert( ap );
     BOOST_CHECK_THROW( (set.replace(set.begin(), 0 )), bad_ptr_container_operation );
     BOOST_CHECK_THROW( (set.replace(set.begin(), std::auto_ptr<int>(0) )), bad_ptr_container_operation );
 

Modified: trunk/libs/ptr_container/test/sequence_test_data.hpp
==============================================================================
--- trunk/libs/ptr_container/test/sequence_test_data.hpp (original)
+++ trunk/libs/ptr_container/test/sequence_test_data.hpp 2010-04-30 20:13:03 EDT (Fri, 30 Apr 2010)
@@ -103,7 +103,8 @@
     c.pop_back();
     BOOST_CHECK( !c.empty() );
     c.insert( c.end(), new T );
- c.insert( c.end(), std::auto_ptr<T>( new T ) );
+ std::auto_ptr<T> ap(new T);
+ c.insert( c.end(), ap );
     BOOST_CHECK_EQUAL( c.size(), 5u );
 
 #if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
@@ -135,7 +136,7 @@
 #else
     auto_type ptr = c.release( c.begin() );
 #endif
- std::auto_ptr<C> ap = c.release();
+ std::auto_ptr<C> ap2 = c.release();
     c = c2.clone();
     BOOST_CHECK( !c.empty() );
     auto_type ptr2 = c.replace( c.begin(), new T );


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk