forked from boostorg/exception
Fixing bug in exception_ptr cloning of error_info objects.
This commit is contained in:
@ -29,8 +29,7 @@ boost
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::string name_value_string() const = 0;
|
virtual std::string name_value_string() const = 0;
|
||||||
|
virtual error_info_base * clone() const = 0;
|
||||||
protected:
|
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
~error_info_base() throw()
|
~error_info_base() throw()
|
||||||
@ -44,6 +43,11 @@ boost
|
|||||||
error_info:
|
error_info:
|
||||||
public exception_detail::error_info_base
|
public exception_detail::error_info_base
|
||||||
{
|
{
|
||||||
|
error_info_base *
|
||||||
|
clone() const
|
||||||
|
{
|
||||||
|
return new error_info<Tag,T>(*this);
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
error_info( value_type const & v ):
|
error_info( value_type const & v ):
|
||||||
|
@ -142,7 +142,11 @@ boost
|
|||||||
refcount_ptr<error_info_container> p;
|
refcount_ptr<error_info_container> p;
|
||||||
error_info_container_impl * c=new error_info_container_impl;
|
error_info_container_impl * c=new error_info_container_impl;
|
||||||
p.adopt(c);
|
p.adopt(c);
|
||||||
c->info_ = info_;
|
for( error_info_map::const_iterator i=info_.begin(),e=info_.end(); i!=e; ++i )
|
||||||
|
{
|
||||||
|
shared_ptr<error_info_base> cp(i->second->clone());
|
||||||
|
c->info_.insert(std::make_pair(i->first,cp));
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -121,9 +121,42 @@ check( boost::shared_ptr<thread_handle> const & t )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_deep_copy()
|
||||||
|
{
|
||||||
|
int const * p1=0;
|
||||||
|
boost::exception_ptr p;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BOOST_THROW_EXCEPTION(exc() << answer(42));
|
||||||
|
BOOST_ERROR("BOOST_THROW_EXCEPTION didn't throw");
|
||||||
|
}
|
||||||
|
catch(
|
||||||
|
exc & e )
|
||||||
|
{
|
||||||
|
p1=boost::get_error_info<answer>(e);
|
||||||
|
p=boost::current_exception();
|
||||||
|
}
|
||||||
|
BOOST_TEST(p1!=0);
|
||||||
|
BOOST_TEST(p);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
boost::rethrow_exception(p);
|
||||||
|
BOOST_ERROR("rethrow_exception didn't throw");
|
||||||
|
}
|
||||||
|
catch(
|
||||||
|
exc & e )
|
||||||
|
{
|
||||||
|
int const * p2=boost::get_error_info<answer>(e);
|
||||||
|
BOOST_TEST(p2!=0 && *p2==42);
|
||||||
|
BOOST_TEST(p2!=p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
test_deep_copy();
|
||||||
BOOST_TEST(++exc_count==1);
|
BOOST_TEST(++exc_count==1);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user