Boost logo

Boost :

Subject: Re: [boost] boost::mpl::for_each and value_initialized
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2010-02-08 06:11:00


>> I'm sorry, MSVC bug #100744 is still there, even though #335987 has
>> been fixed. VC9 deals with POD types correctly, but may not do so
>> for non-POD aggregate class types.

Domagoj Saric wrote:
> but if this is so, shouldn't the proposed patch atleast be
> modified to:
>
> #ifdef BOOST_VALUE_INITIALIZATION_NEEDS_MEMSET
> if
> (
> !(
> ( _MSC_VER >= 1500 ) &&
> ( is_pod<T>::value )
> )
> )
> std::memset(&x, 0, sizeof(x));
>
> #endif
> ?

I would consider that a refinement. But it's not that simple. MSVC does
value-initialize a lot of non-POD types correctly! (But not all of them.)
Other compilers may value-initialize built-in types correctly, but not
aggregates. I can't remember exactly.

So I'd rather start by committing the simple fix that I proposed at
Aleksey's ticket #3869, "Unconditional call to memset in
value_initialized()", https://svn.boost.org/trac/boost/ticket/3869

Note that I'm planning to rename the macro to
BOOST_NO_PROPER_VALUE_INITIALIZATION_FOR_ALL_TYPES. I hope that's okay. But
before I commit I'll have to write unit tests for this macro, as John
explained to me. I'm planning to do so later this month.

When all that is done and stabilized, I wouldn't mind looking at some
possible fine tuning, to further reduce the number of memset calls. But I'm
afraid it will be a maintainer's headache.

Kind regards,

  Niels

--
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center 

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk