Ticket #3869: value_init_workaround.patch

File value_init_workaround.patch, 1.6 KB (added by niels_dekker, 12 years ago)

Made memset call conditional, based on BOOST_NO_COMPLETE_VALUE_INITIALIZATION

  • boost/utility/value_init.hpp

     
    1010// 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola
    1111// 20 Feb 2009 (Fixed logical const-ness issues) Niels Dekker, Fernando Cacciola
    1212// 03 Apr 2010 (Added initialized<T>, suggested by Jeffrey Hellrung, fixing #3472) Niels Dekker
     13// 16 May 2010 (Made memset call conditional, fixing #3869) Niels Dekker
    1314//
    1415#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
    1516#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
     
    2122// contains. More details on these issues are at libs/utility/value_init.htm
    2223
    2324#include <boost/aligned_storage.hpp>
     25#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
    2426#include <boost/detail/workaround.hpp>
    2527#include <boost/static_assert.hpp>
    2628#include <boost/type_traits/cv_traits.hpp>
     
    4143#endif
    4244#endif
    4345
     46#ifndef BOOST_DETAIL_VALUE_INIT_WORKAROUND
     47  #ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION
     48  #define BOOST_DETAIL_VALUE_INIT_WORKAROUND 1
     49  #else
     50  #define BOOST_DETAIL_VALUE_INIT_WORKAROUND 0
     51  #endif
     52#endif
     53
    4454namespace boost {
    4555
    4656template<class T>
     
    8292
    8393    initialized()
    8494    {
    85       // Note: the following memset call will become conditional when ticket #3869 is fixed:
    86       // https://svn.boost.org/trac/boost/ticket/3869 reported by Aleksey Gurtovoy.
     95#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
    8796      std::memset(&x, 0, sizeof(x));
    88 
     97#endif
    8998      new (wrapper_address()) wrapper();
    9099    }
    91100