Boost logo

Boost :

From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2006-10-30 07:18:51

From: Felipe Magno de Almeida

> On 10/30/06, Anthony Williams <anthony_w.geo_at_[hidden]> wrote:
>> Roland Schwarz <roland.schwarz_at_[hidden]> writes:
>> [snipped]
>>> Do you mean: the object might be already zero initialized before
>>> the ctor runs? If yes: this is very dangerous to rely on!
>> No. This is required. The memory for an object with
>> static-storage-duration MUST be zero initialized prior to the
>> constructor running.
> It dont even matter, it *must* not have a constructor. Or else
> there'll be a race condition on the compiler's flag and multiple
> constructor calls.

Does this matter if all the constructor does is repeat the zero
initialization? (Serious question. The answer is not obvious to me).

Roland suggested a mutex which relied on the zero initialization of
static PODs. He then listed a number of issues that maintaining POD
status introduces (like we can't eliminate copy constructors). I
pointed out that actually ALL static objects are zero initialized, so we
could have a default constructor that does nothing or repeats the zero
initialization (which means we could create the mutex other than as a
object with other than static storage duration).

Martin Bonner
Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB24 6WZ,
ENGLAND Tel: +44 (0)1223 203894

Boost list run by bdawes at, gregod at, cpdaniel at, john at