Index: boost/config/compiler/borland.hpp =================================================================== --- boost/config/compiler/borland.hpp (revision 61120) +++ boost/config/compiler/borland.hpp (working copy) @@ -261,6 +261,11 @@ # define BOOST_NO_VOID_RETURNS #endif +// Borland has not completely implemented value-initialization: +// http://qc.embarcadero.com/wc/qcmain.aspx?rc=51854 +// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION + #define BOOST_COMPILER "Borland C++ version " BOOST_STRINGIZE(__BORLANDC__) Index: boost/config/compiler/codegear.hpp =================================================================== --- boost/config/compiler/codegear.hpp (revision 61120) +++ boost/config/compiler/codegear.hpp (working copy) @@ -19,8 +19,8 @@ #endif // // versions check: -// last known and checked version is 0x620 -#if (__CODEGEARC__ > 0x620) +// last known and checked version is 0x621 +#if (__CODEGEARC__ > 0x621) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # else @@ -41,7 +41,7 @@ #endif // CodeGear C++ Builder 2010 -#if (__CODEGEARC__ <= 0x620) +#if (__CODEGEARC__ <= 0x621) # define BOOST_NO_TYPENAME_WITH_CTOR // Cannot use typename keyword when making temporaries of a dependant type # define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS @@ -159,5 +159,11 @@ # define BOOST_NO_VOID_RETURNS #endif +// Codegear has not completely implemented value-initialization: +// http://qc.embarcadero.com/wc/qcmain.aspx?rc=51854 +// Note: This issue is reported as fixed by build number 12.0.3140.16150 +// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION + #define BOOST_COMPILER "CodeGear C++ version " BOOST_STRINGIZE(__CODEGEARC__) Index: boost/config/compiler/gcc.hpp =================================================================== --- boost/config/compiler/gcc.hpp (revision 61120) +++ boost/config/compiler/gcc.hpp (working copy) @@ -69,6 +69,14 @@ # endif #endif +#if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 ) +// Previous versions of GCC did not completely implement value-initialization: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111 (fixed for GCC 4.4) +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 (fixed for GCC 4.2.4) +// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION +#endif + #ifndef __EXCEPTIONS # define BOOST_NO_EXCEPTIONS #endif Index: boost/config/compiler/sunpro_cc.hpp =================================================================== --- boost/config/compiler/sunpro_cc.hpp (revision 61120) +++ boost/config/compiler/sunpro_cc.hpp (working copy) @@ -75,6 +75,13 @@ #define BOOST_NO_TWO_PHASE_NAME_LOOKUP #define BOOST_NO_ADL_BARRIER +// The Sun compiler has not completely implemented value-initialization. +// Note: I do not know if this issue is there in all versions of the Sun compiler. +// (Niels Dekker, April 2010) +// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION + + // // C++0x features // Index: boost/config/compiler/visualc.hpp =================================================================== --- boost/config/compiler/visualc.hpp (revision 61120) +++ boost/config/compiler/visualc.hpp (working copy) @@ -99,6 +99,12 @@ # define BOOST_NO_ADL_BARRIER #endif +// Microsoft Visual C++ has not completely implemented value-initialization: +// https://connect.microsoft.com/VisualStudio/feedback/details/100744 +// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION + + #if _MSC_VER <= 1500 || !defined(BOOST_STRICT_CONFIG) // 1500 == VC++ 9.0 # define BOOST_NO_INITIALIZER_LISTS #endif Index: libs/config/doc/macro_reference.qbk =================================================================== --- libs/config/doc/macro_reference.qbk (revision 61120) +++ libs/config/doc/macro_reference.qbk (working copy) @@ -49,6 +49,10 @@ [[`BOOST_NO_AUTO_PTR`][Standard library][ If the compiler / library supplies non-standard or broken `std::auto_ptr`. ]] +[[`BOOST_NO_COMPLETE_VALUE_INITIALIZATION`][Compiler][ +Compiler has not completely implemented value-initialization. +See also [@../../utility/value_init.htm#compiler_issues `utility/value_init.htm#compiler_issues`] +]] [[`BOOST_NO_CTYPE_FUNCTIONS`][Platform][ The Platform does not provide functions for the character-classifying operations `` and ``, only macros. Index: libs/config/test/Jamfile.v2 =================================================================== --- libs/config/test/Jamfile.v2 (revision 61120) +++ libs/config/test/Jamfile.v2 (working copy) @@ -46,6 +46,7 @@ [ run math_info.cpp : : : always_show_run_output borland:static borland:static ] [ run abi/abi_test.cpp abi/main.cpp ] [ run limits_test.cpp ../../test/build//boost_test_exec_monitor ] + [ run no_complete_value_initialization.cpp ] [ run link/main.cpp link//link_test : #args : #input-files Index: libs/config/test/no_complete_value_initialization.cpp =================================================================== --- libs/config/test/no_complete_value_initialization.cpp (revision 0) +++ libs/config/test/no_complete_value_initialization.cpp (revision 0) @@ -0,0 +1,198 @@ +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for most recent version. + +// MACRO: BOOST_NO_COMPLETE_VALUE_INITIALIZATION +// TITLE: No complete value-initialization +// DESCRIPTION: This macro must be defined, if and only if the compiler +// does not to have implemented value-initialization completely. +// See also boost/libs/utility/value_init.htm#compiler_issues + +#include +#include +#include + +namespace +{ + enum enum_type { negative_number = -1, magic_number = 42 }; + + // A POD struct. + struct pod_struct + { + enum_type e; + char c; + unsigned char uc; + short s; + int i; + unsigned u; + long l; + float f; + double d; + void* p; + }; + + bool is_zero_initialized(const pod_struct& arg) + { + return + arg.e == 0 && + arg.c == 0 && + arg.uc == 0 && + arg.s == 0 && + arg.i == 0 && + arg.u == 0 && + arg.l == 0 && + arg.f == 0 && + arg.d == 0 && + arg.p == 0; + } + + // A class that holds a "magic" enum value. + class enum_holder + { + enum_type m_enum; + public: + + enum_holder() + : + m_enum(magic_number) + { + } + + bool is_default() const + { + return m_enum == magic_number; + } + }; + + + // A class that is not a POD type. + class non_pod_class + { + private: + enum_holder m_enum_holder; + + public: + int i; + + virtual bool is_value_initialized() const + { + return m_enum_holder.is_default() && i == 0; + } + + virtual ~non_pod_class() {} + }; + + // The first argument (is_value_initializated) tells whether value initialization + // has succeeded. + // The second argument tells what expression was evaluated. + bool is_true(bool is_value_initializated, const char *const expression) + { + if ( ! is_value_initializated ) + { +#ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION + std::cout + << "Information: " << expression << " evaluated to false.\n" + << " Therefor BOOST_NO_COMPLETE_VALUE_INITIALIZATION is defined for this compiler." + << std::endl; +#else + std::cerr + << "Error: " << expression << " evaluated to false.\n" + << " Please consider defining BOOST_NO_COMPLETE_VALUE_INITIALIZATION for this compiler." + << std::endl; +#endif + } + return is_value_initializated; + } + +#define IS_TRUE(value) is_true(value, #value) +#define IS_ZERO(value) is_true(value == 0, #value " == 0") + + // The default constructor of this class initializes each of its + // data members by means of an empty set of parentheses, and checks + // whether each of them is value-initialized. + class value_initializer + { + private: + enum_holder m_enum_holder; + enum_type m_enum; + char m_char; + unsigned char m_unsigned_char; + short m_short; + int m_int; + unsigned m_unsigned; + long m_long; + float m_float; + double m_double; + void* m_ptr; + pod_struct m_pod; + pod_struct m_pod_array[2]; + non_pod_class m_non_pod; + non_pod_class m_non_pod_array[2]; + + public: + value_initializer() + : + m_enum_holder(), + m_enum(), + m_char(), + m_unsigned_char(), + m_short(), + m_int(), + m_unsigned(), + m_long(), + m_float(), + m_double(), + m_ptr(), + m_pod(), + m_pod_array(), + m_non_pod(), + m_non_pod_array() + { + } + + // Returns the number of failures. + unsigned check() const + { + return + (IS_TRUE( m_enum_holder.is_default() ) ? 0 : 1) + + (IS_ZERO(m_enum) ? 0 : 1) + + (IS_ZERO(m_char) ? 0 : 1) + + (IS_ZERO(m_unsigned_char) ? 0 : 1) + + (IS_ZERO(m_short) ? 0 : 1) + + (IS_ZERO(m_int) ? 0 : 1) + + (IS_ZERO(m_unsigned) ? 0 : 1) + + (IS_ZERO(m_long) ? 0 : 1) + + (IS_ZERO(m_float) ? 0 : 1) + + (IS_ZERO(m_double) ? 0 : 1) + + (IS_ZERO(m_ptr) ? 0 : 1) + + (IS_TRUE( is_zero_initialized(m_pod) ) ? 0 : 1) + + (IS_TRUE( m_non_pod.is_value_initialized() ) ? 0 : 1) + + (IS_TRUE( is_zero_initialized(m_pod_array[0]) + && is_zero_initialized(m_pod_array[1]) ) ? 0 : 1) + + (IS_TRUE( m_non_pod_array[0].is_value_initialized() + && m_non_pod_array[1].is_value_initialized() ) ? 0 : 1); + + } + }; + +} // End of namespace. + +int main(int, char*[]) +{ + // Check both value-initialization on the stack and on the heap: + const unsigned num_failures_on_stack = value_initializer().check(); + const value_initializer* const ptr = new value_initializer(); + const unsigned num_failures_on_heap = ptr->check(); + delete ptr; + + const bool completely_value_initialized = + num_failures_on_stack == 0 && num_failures_on_heap == 0; + +#ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION + return completely_value_initialized ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return completely_value_initialized ? EXIT_SUCCESS : EXIT_FAILURE; +#endif +}