Re: ctor unnecessarily wiping of PODs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 March 2012 18:27, Hite, Christopher wrote:
> Thanks for the quick response.
>> The C++ standard says that for a POD type the initializer () will cause it to be zero-initialized.
> No the standard says: If I don't init the POD with an initializer or otherwise, I have to expect dirty memory there.

Where does it say that?

[dcl.init] paragraph 10 says "An object whose initializer is an empty
set of parentheses, i.e., (), shall be value-initialized."

[dcl.init] paragraph 11 says "If no initializer is specified for an
object, the object is default-initialized; if no initialization is
performed, an object with automatic or dynamic storage duration has
indeterminate value."

Your example has an initializer which is an empty set of parentheses.


> n and u are being inited even with the default constructor.  With ctor uncommented I would expect n() to init just n and the array to be uninitialized.

Correct.  Which is what I see with GCC 4.6.1 or later (I don't have
4.6.0 available)

>> If that's not what you want, use:
>>      new (v) Ray2;
>> void makeRay(void*v){
>>       new(v)Ray2;
>> }
> Does the same thing.  Semantics are identical.

Not for me.

It's possible this was a bug in 4.6.0 that is fixed in the current release.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux