$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: emil_at_[hidden]
Date: 2008-06-11 14:24:11
Author: emildotchevski
Date: 2008-06-11 14:24:10 EDT (Wed, 11 Jun 2008)
New Revision: 46333
URL: http://svn.boost.org/trac/boost/changeset/46333
Log:
Fixed exception info bug when boost::exception is derived virtually.
Text files modified: 
   trunk/boost/exception/enable_current_exception.hpp |     6 +++++                                   
   trunk/libs/exception/test/helper2.cpp              |    43 ++++++++++++++++++++++++++++----------- 
   trunk/libs/exception/test/helper2.hpp              |    29 +++++++++++++++++++-------              
   trunk/libs/exception/test/throw_exception_test.cpp |    13 +++++++----                             
   4 files changed, 66 insertions(+), 25 deletions(-)
Modified: trunk/boost/exception/enable_current_exception.hpp
==============================================================================
--- trunk/boost/exception/enable_current_exception.hpp	(original)
+++ trunk/boost/exception/enable_current_exception.hpp	2008-06-11 14:24:10 EDT (Wed, 11 Jun 2008)
@@ -64,6 +64,9 @@
             clone_impl( T const & x ):
                 T(x)
                 {
+                if( boost::exception * be1=dynamic_cast<boost::exception *>(this) )
+                    if( boost::exception const * be2=dynamic_cast<T const *>(&x) )
+                        *be1 = *be2;
                 }
 
             private:
@@ -88,6 +91,9 @@
                 T(x),
                 count_(0)
                 {
+                if( boost::exception * be1=dynamic_cast<boost::exception *>(this) )
+                    if( boost::exception const * be2=dynamic_cast<T const *>(&x) )
+                        *be1 = *be2;
                 }
 
             private:
Modified: trunk/libs/exception/test/helper2.cpp
==============================================================================
--- trunk/libs/exception/test/helper2.cpp	(original)
+++ trunk/libs/exception/test/helper2.cpp	2008-06-11 14:24:10 EDT (Wed, 11 Jun 2008)
@@ -13,41 +13,60 @@
     exception_test
         {
         inline
-        some_boost_exception::
-        some_boost_exception( int x ):
+        derives_boost_exception::
+        derives_boost_exception( int x ):
             x_(x)
             {
             }
 
-        some_boost_exception::
-        ~some_boost_exception() throw()
+        derives_boost_exception::
+        ~derives_boost_exception() throw()
             {
             }
 
         inline
-        some_std_exception::
-        some_std_exception( int x ):
+        derives_boost_exception_virtually::
+        derives_boost_exception_virtually( int x ):
             x_(x)
             {
             }
 
-        some_std_exception::
-        ~some_std_exception() throw()
+        derives_boost_exception_virtually::
+        ~derives_boost_exception_virtually() throw()
             {
             }
 
+        inline
+        derives_std_exception::
+        derives_std_exception( int x ):
+            x_(x)
+            {
+            }
+
+        derives_std_exception::
+        ~derives_std_exception() throw()
+            {
+            }
+
+        template <>
+        void
+        throw_test_exception<derives_boost_exception>( int x )
+            {
+            boost::throw_exception( derives_boost_exception(x) );
+            }
+
         template <>
         void
-        throw_test_exception<some_boost_exception>( int x )
+        throw_test_exception<derives_boost_exception_virtually>( int x )
             {
-            boost::throw_exception( some_boost_exception(x) );
+            boost::throw_exception( derives_boost_exception_virtually(x) );
             }
 
         template <>
         void
-        throw_test_exception<some_std_exception>( int x )
+        throw_test_exception<derives_std_exception>( int x )
             {
-            boost::throw_exception( some_std_exception(x) );
+            boost::throw_exception( derives_std_exception(x) );
             }
         }
     }
Modified: trunk/libs/exception/test/helper2.hpp
==============================================================================
--- trunk/libs/exception/test/helper2.hpp	(original)
+++ trunk/libs/exception/test/helper2.hpp	2008-06-11 14:24:10 EDT (Wed, 11 Jun 2008)
@@ -16,21 +16,31 @@
     exception_test
         {
         struct
-        some_boost_exception:
+        derives_boost_exception:
             public boost::exception,
             public std::exception
             {
-            explicit some_boost_exception( int x );
-            virtual ~some_boost_exception() throw();
+            explicit derives_boost_exception( int x );
+            virtual ~derives_boost_exception() throw();
             int x_;
             };
 
         struct
-        some_std_exception:
+        derives_boost_exception_virtually:
+            public virtual boost::exception,
             public std::exception
             {
-            explicit some_std_exception( int x );
-            virtual ~some_std_exception() throw();
+            explicit derives_boost_exception_virtually( int x );
+            virtual ~derives_boost_exception_virtually() throw();
+            int x_;
+            };
+
+        struct
+        derives_std_exception:
+            public std::exception
+            {
+            explicit derives_std_exception( int x );
+            virtual ~derives_std_exception() throw();
             int x_;
             };
 
@@ -38,10 +48,13 @@
         void throw_test_exception( int );
 
         template <>
-        void throw_test_exception<some_boost_exception>( int );
+        void throw_test_exception<derives_boost_exception>( int );
+
+        template <>
+        void throw_test_exception<derives_boost_exception_virtually>( int );
 
         template <>
-        void throw_test_exception<some_std_exception>( int );
+        void throw_test_exception<derives_std_exception>( int );
         }
     }
 
Modified: trunk/libs/exception/test/throw_exception_test.cpp
==============================================================================
--- trunk/libs/exception/test/throw_exception_test.cpp	(original)
+++ trunk/libs/exception/test/throw_exception_test.cpp	2008-06-11 14:24:10 EDT (Wed, 11 Jun 2008)
@@ -8,7 +8,7 @@
 #include <boost/exception_ptr.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
-typedef boost::error_info<struct tag_test_int,int> test_int;
+typedef boost::error_info<struct tag_test_int,int> test_data;
 
 void
 throw_fwd( void (*thrower)(int) )
@@ -20,7 +20,7 @@
     catch(
     boost::exception & x )
         {
-        x << test_int(42);
+        x << test_data(42);
         throw;
         }
     }
@@ -46,7 +46,9 @@
         catch(
         T & y )
             {
-            BOOST_TEST(*boost::get_error_info<test_int>(y)==42);
+            BOOST_TEST(boost::get_error_info<test_data>(y));
+            if( boost::shared_ptr<int const> d=boost::get_error_info<test_data>(y) )
+                BOOST_TEST(*d==42);
             BOOST_TEST(y.x_==42);
             }
         catch(
@@ -60,7 +62,8 @@
 int
 main()
     {
-    tester<boost::exception_test::some_boost_exception>();
-    tester<boost::exception_test::some_std_exception>();
+    tester<boost::exception_test::derives_boost_exception>();
+    tester<boost::exception_test::derives_boost_exception_virtually>();
+    tester<boost::exception_test::derives_std_exception>();
     return boost::report_errors();
     }