From 913ed354d7dd574c7c624ac652c4593981f2daad Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Nov 2007 22:03:59 +0000 Subject: [PATCH] Merged revisions 41399-41442 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41400 | igaztanaga | 2007-11-26 08:34:13 -0800 (Mon, 26 Nov 2007) | 1 line Added missing #include ........ r41401 | anthonyw | 2007-11-26 09:01:08 -0800 (Mon, 26 Nov 2007) | 1 line once_flag uses zero-initialization on POSIX as well as windows ........ r41402 | niels_dekker | 2007-11-26 09:36:52 -0800 (Mon, 26 Nov 2007) | 1 line Marked value_init_test failures on Borland C++ as "expected failures", as discussed with Fernando Cacciola. ........ r41404 | rwgk | 2007-11-26 12:46:28 -0800 (Mon, 26 Nov 2007) | 1 line g++ 4.3.0 compatibility (4.3.0 20071125 (experimental)) ........ r41405 | anthonyw | 2007-11-26 13:15:04 -0800 (Mon, 26 Nov 2007) | 1 line reverted accidental checkin of new timed_wait functions on condition_variable ........ r41406 | nasonov | 2007-11-26 13:29:04 -0800 (Mon, 26 Nov 2007) | 3 lines Remove redundant BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION. ........ r41407 | chris_kohlhoff | 2007-11-26 13:29:38 -0800 (Mon, 26 Nov 2007) | 3 lines WinCE doesn't work with all multicast addresses, and even though it doesn't support the multicast::enable_loopback option you can still get the value. ........ r41408 | dave | 2007-11-26 14:01:50 -0800 (Mon, 26 Nov 2007) | 2 lines Try to extend the workaround to SunPro 5.9, since we're marked as not working on 5.8 ........ r41409 | dave | 2007-11-26 17:40:01 -0800 (Mon, 26 Nov 2007) | 3 lines Allow Sun-5.7 and Sun-5.8 to fail loudly for Boost.Python so I can see what's really wrong. ........ r41413 | anthonyw | 2007-11-27 06:24:29 -0800 (Tue, 27 Nov 2007) | 1 line add support for relative timeouts to condition timed_wait ........ r41414 | grafik | 2007-11-27 09:53:56 -0800 (Tue, 27 Nov 2007) | 1 line Remove non-existent option info. ........ r41415 | grafik | 2007-11-27 09:55:13 -0800 (Tue, 27 Nov 2007) | 1 line Add some utility output formatting functions. ........ r41416 | grafik | 2007-11-27 09:57:15 -0800 (Tue, 27 Nov 2007) | 1 line Check empty string invariants, instead of assuming all strings are allocated. And reset strings when they are freed. ........ r41417 | grafik | 2007-11-27 09:58:50 -0800 (Tue, 27 Nov 2007) | 1 line Fix buffer overrun bug in expanding @() subexpressions. ........ r41418 | hkaiser | 2007-11-27 10:18:10 -0800 (Tue, 27 Nov 2007) | 1 line Wave: Fixed gcc warning, bumped version number. ........ r41419 | djenkins | 2007-11-27 10:57:48 -0800 (Tue, 27 Nov 2007) | 1 line Changes for msvc-9.0 /clr flag ........ r41420 | djenkins | 2007-11-27 10:59:06 -0800 (Tue, 27 Nov 2007) | 1 line Changes for msvc-9.0 /clr flag ........ r41423 | niels_dekker | 2007-11-27 13:34:08 -0800 (Tue, 27 Nov 2007) | 1 line Added value_init test for struct as used in MSVC bug report regarding value-initialization. ........ r41429 | noel_belcourt | 2007-11-27 18:27:13 -0800 (Tue, 27 Nov 2007) | 3 lines Fix pathscale rpath issue per Alain Minussi's suggestion. ........ r41430 | grafik | 2007-11-27 23:08:13 -0800 (Tue, 27 Nov 2007) | 1 line Add test for result status values of simple actions, i.e. empty actions. ........ r41431 | grafik | 2007-11-27 23:21:49 -0800 (Tue, 27 Nov 2007) | 19 lines build-system.jam * Reflect added start/end timestamps for actions in xml output. And update action rules for new args. execcmd.h * Add start/end timestamps to action timing info. execnt.c * Fix filetime_seconds calculation when time is larger than low 32 bit value. * Add calc of C time_t from Windows FILETIME. * Add start/end timestamps recording to action timing info. execunix.c * Add start/end timestamps recording to action timing info. jam.c * Change JAMDATE to use common ISO date format. make1.c * Redo __TIMING_RULE__ and __ACTION__RULE__ invocations to new argument ordering and added end/result timestamp values. ........ r41432 | chris_kohlhoff | 2007-11-28 05:26:33 -0800 (Wed, 28 Nov 2007) | 3 lines Make async operations fail with an error if the socket descriptor doesn't fit into the select call's fd_set. ........ r41433 | bgubenko | 2007-11-28 07:33:16 -0800 (Wed, 28 Nov 2007) | 1 line add "gcc*hpux*" toolset for serialization library bug on big endian platforms ........ r41436 | niels_dekker | 2007-11-28 09:19:37 -0800 (Wed, 28 Nov 2007) | 1 line Added tests for two more struct types to value_init_test -- discussed with Fernando Cacciola ........ r41439 | bgubenko | 2007-11-28 11:04:53 -0800 (Wed, 28 Nov 2007) | 1 line add "-lrt" for acc* toolsets ........ r41440 | grafik | 2007-11-28 12:24:17 -0800 (Wed, 28 Nov 2007) | 1 line Fix for latest Doxygen namespace file names. And support for method groups. From Samuel Debionne. ........ [SVN r41444] --- value_init_test.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/value_init_test.cpp b/value_init_test.cpp index 4c576a6..5187a77 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -73,6 +73,58 @@ struct AggregatePODStruct 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 ; } + + +// +// 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 for a specific type T. @@ -123,13 +175,27 @@ int test_main(int, char **) 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) ); + + 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; } unsigned int expected_failures = 0; - - - - -