Re: [RFC] Interim review: typedefs.h / protos.h splitting

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Tue, 18 Sep 2012 18:20:46 -0600

On 09/18/2012 06:01 PM, Amos Jeffries wrote:
>>> Maybe the
>>> initializations are silently done? Or a memset is done? I suspect it
>>> is undefined in the standard.
>> It is very well defined. In general, you do not pay for what you do not
>> use in C++, in part to achieve partial backwards compatibility with C.
>> There is no magic :-).
>>
>
> I thought it was guaranteed that a class was initialized to zero?

C++ itself guarantees that no initialization will happen. This is why
folks are able to allocate C++ objects in special places such as
hardware registers or shared memory. Squid probably does not do that,
but it is possible.

Some Squid objects' memory is memset() to zero via memory pools or other
"3rd party" memory management mechanisms. This is why some classes do
not have proper constructors but things still work. However, C++ itself
does not initialize anything by default, just like C.

Since RequestFlags are not pooled, they should be properly initialized
IMO (even though it may be a waste from performance point of view
because all their current containers such as HttpRequest may zero their
memory anyway -- I did not check whether that is true though).

> and
> that we only needed to provide explicit constructor details for members
> which needed other setup?

If we do not want to rely on things like memory pools to initialize
object memory, then constructors must initialize every data member.

Cheers,

Alex.
Received on Wed Sep 19 2012 - 00:21:09 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 19 2012 - 12:00:07 MDT