Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82915 - in trunk: boost/optional libs/optional/test
From: steven_at_[hidden]
Date: 2013-02-15 14:22:34


Author: steven_watanabe
Date: 2013-02-15 14:22:34 EST (Fri, 15 Feb 2013)
New Revision: 82915
URL: http://svn.boost.org/trac/boost/changeset/82915

Log:
Work around msvc bug when explicitly destroying a class with a virtual base. Fixes #5940.
Text files modified:
   trunk/boost/optional/optional.hpp | 2 +-
   trunk/libs/optional/test/optional_test.cpp | 8 ++++++++
   2 files changed, 9 insertions(+), 1 deletions(-)

Modified: trunk/boost/optional/optional.hpp
==============================================================================
--- trunk/boost/optional/optional.hpp (original)
+++ trunk/boost/optional/optional.hpp 2013-02-15 14:22:34 EST (Fri, 15 Feb 2013)
@@ -476,7 +476,7 @@
 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
     void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; m_initialized = false ; }
 #else
- void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->T::~T() ; m_initialized = false ; }
+ void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->~T() ; m_initialized = false ; }
 #endif
 
     void destroy_impl ( is_reference_tag ) { m_initialized = false ; }

Modified: trunk/libs/optional/test/optional_test.cpp
==============================================================================
--- trunk/libs/optional/test/optional_test.cpp (original)
+++ trunk/libs/optional/test/optional_test.cpp 2013-02-15 14:22:34 EST (Fri, 15 Feb 2013)
@@ -840,11 +840,19 @@
   test_none( ARG(double) ) ;
 }
 
+// MSVC < 11.0 doesn't destroy X when we call ptr->VBase::VBase.
+// Make sure that we work around this bug.
+struct VBase : virtual X
+{
+ VBase(int v) : X(v) {}
+};
+
 void test_with_class_type()
 {
   TRACE( std::endl << BOOST_CURRENT_FUNCTION );
 
   test_basics( ARG(X) );
+ test_basics( ARG(VBase) );
   test_conditional_ctor_and_get_valur_or( ARG(X) );
   test_direct_value_manip( ARG(X) );
   test_uninitialized_access( ARG(X) );


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