Boost logo

Boost-Commit :

From: nielsdekker_at_[hidden]
Date: 2007-11-28 12:19:37


Author: niels_dekker
Date: 2007-11-28 12:19:37 EST (Wed, 28 Nov 2007)
New Revision: 41436
URL: http://svn.boost.org/trac/boost/changeset/41436

Log:
Added tests for two more struct types to value_init_test -- discussed with Fernando Cacciola
Text files modified:
   trunk/libs/utility/value_init_test.cpp | 48 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 48 insertions(+), 0 deletions(-)

Modified: trunk/libs/utility/value_init_test.cpp
==============================================================================
--- trunk/libs/utility/value_init_test.cpp (original)
+++ trunk/libs/utility/value_init_test.cpp 2007-11-28 12:19:37 EST (Wed, 28 Nov 2007)
@@ -91,6 +91,42 @@
 
 
 //
+// A struct that has an explicit (user defined) destructor.
+// Some compilers do not correctly value-initialize such a struct, for example:
+// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression"
+// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
+//
+struct StructWithDestructor
+{
+ int i;
+ ~StructWithDestructor() {}
+};
+
+bool operator == ( StructWithDestructor const& lhs, StructWithDestructor const& rhs )
+{ return lhs.i == rhs.i ; }
+
+
+//
+// A struct that has a virtual function.
+// Some compilers do not correctly value-initialize such a struct either, for example:
+// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression"
+// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
+//
+struct StructWithVirtualFunction
+{
+ int i;
+ virtual void VirtualFunction();
+};
+
+void StructWithVirtualFunction::VirtualFunction()
+{
+}
+
+bool operator == ( StructWithVirtualFunction const& lhs, StructWithVirtualFunction const& rhs )
+{ return lhs.i == rhs.i ; }
+
+
+//
 // This test function tests boost::value_initialized<T> for a specific type T.
 // The first argument (y) is assumed have the value of a value-initialized object.
 // Returns true on success.
@@ -146,6 +182,18 @@
   stringAndInt1.s = std::string("1");
   BOOST_CHECK ( test(stringAndInt0, stringAndInt1) );
 
+ StructWithDestructor structWithDestructor0;
+ StructWithDestructor structWithDestructor1;
+ structWithDestructor0.i = 0;
+ structWithDestructor1.i = 1;
+ BOOST_CHECK ( test(structWithDestructor0, structWithDestructor1) );
+
+ StructWithVirtualFunction structWithVirtualFunction0;
+ StructWithVirtualFunction structWithVirtualFunction1;
+ structWithVirtualFunction0.i = 0;
+ structWithVirtualFunction1.i = 1;
+ BOOST_CHECK ( test(structWithVirtualFunction0, structWithVirtualFunction1) );
+
   return 0;
 }
 


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