RE: ctor unnecessarily wiping of PODs

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

 



> Paragraph 7
I'm using n3242.  I can't seem to download
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3290.pdf


If no initializer is specified for an object, and the object is of (possibly cv-qualified) non-POD class type (or array
thereof), the object shall be default-initialized; if the object is of const-qualified type, the underlying class type shall
have a user-declared default constructor. Otherwise, if no initializer is specified for a non-static object, the object and
its subobjects, if any, have an indeterminate initial value); if the object or any of its subobjects are of const-qualified
type, the program is ill-formed.

I'm going to break the above down like a lawyer:

1) If no initializer is specified for an object, and the object is of (possibly cv-qualified) non-POD class type (or array thereof), the object shall be default-initialized;

So Ray2() calls Ray().

2) The implicitly-defined default constructor performs the set of initializations of the class that would be  performed by a user-written default constructor for that class with no ctor-initializer (12.6.2) and an empty compound-statement.

So if Ray() is commented out.  It's the same as: 
	Ray(){}

3)  If no initializer is specified for an object, the object is default-initialized

So n and u are "default-initialized"

4) To default-initialize an object of type T means:
- if T is a (possibly cv-qualified) class type (Clause 9), the default constructor for T is called (and the
initialization is ill-formed if T has no accessible default constructor);
- if T is an array type, each element is default-initialized;
- otherwise, no initialization is performed.

So I would expect the 3rd case here " no initialization is performed" for n and u.

I think I've got this now, but it was a big unclear at first.  Are we on the same page now?

Chris



[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