Boost logo

Boost-Commit :

From: nielsdekker_at_[hidden]
Date: 2007-11-27 16:34:08


Author: niels_dekker
Date: 2007-11-27 16:34:08 EST (Tue, 27 Nov 2007)
New Revision: 41423
URL: http://svn.boost.org/trac/boost/changeset/41423

Log:
Added value_init test for struct as used in MSVC bug report regarding value-initialization.
Text files modified:
   trunk/libs/utility/value_init_test.cpp | 28 +++++++++++++++++++++++-----
   1 files changed, 23 insertions(+), 5 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-27 16:34:08 EST (Tue, 27 Nov 2007)
@@ -73,6 +73,22 @@
 bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs )
 { return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; }
 
+//
+// An aggregate struct that contains an std::string and an int.
+// Pavel Kuznetsov (MetaCommunications Engineering) used a struct like
+// this to reproduce the Microsoft Visual C++ compiler bug, reported as
+// Feedback ID 100744, "Value-initialization in new-expression"
+// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
+//
+struct StringAndInt
+{
+ std::string s;
+ int i;
+};
+
+bool operator == ( StringAndInt const& lhs, StringAndInt const& rhs )
+{ return lhs.s == rhs.s && lhs.i == rhs.i ; }
+
 
 //
 // This test function tests boost::value_initialized<T> for a specific type T.
@@ -123,13 +139,15 @@
   AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 };
   BOOST_CHECK ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) );
 
+ StringAndInt stringAndInt0;
+ StringAndInt stringAndInt1;
+ stringAndInt0.i = 0;
+ stringAndInt1.i = 1;
+ stringAndInt1.s = std::string("1");
+ BOOST_CHECK ( test(stringAndInt0, stringAndInt1) );
+
   return 0;
 }
 
 
 unsigned int expected_failures = 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