This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: ctor unnecessarily wiping of PODs


> [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."
That's my case.  I don't have an initializer for the array or even n since the ctor is commented out.

Note  
	new(v) Ray; 
Does exactly what it should.  The bug crops up in the derived class's constructor.  Why should Ray2() do more work than Ray()?


> > 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)
Ok I think we're on the same page here.

> >> 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.
Are you sure 
     new(v)Ray2;
and
     new(v)Ray2();
produce different code for you?  I'd be very surprised.  Both should call Ray2's default constructor.  I've never heard of a "default constructor" and sperate "default and clearing constructor".

> It's possible this was a bug in 4.6.0 that is fixed in the current release.
I suppose.  If you give me some reason to think it went away, I'll go grab the latest version and build it.

Does your version generate a constructor for Ray2 that doesn't loop over 1kB of data setting it to zero?

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]