www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Where should the destruction of aggregate members take place?

reply "Henning Pohl" <henning still-hidden.de> writes:
a) In the so-called "whole dtor" which calls the dtors of all 
members including the dtor declared (if any). The attributes of 
the "whole dtor" are deduced.

b) Everything takes place in the dtor declared (if any). If the 
dtor is pure/nothrow/safe, it is guaranteed that the object can 
be destructed purely/without throwing/safely. This will break 
existing code.

-----
struct S { ~this() { } }
struct SX { S s; pure ~this() { } }
-----

a) Compiles.
b) Error: S.s.~this is impure

Both behaviors are available on github:
a) https://github.com/D-Programming-Language/dmd/pull/2006
b) https://github.com/D-Programming-Language/dmd/pull/2003

You can apply this to postblit, too.
May 10 2013
parent Kenji Hara <k.hara.pg gmail.com> writes:
2013/5/11 Henning Pohl <henning still-hidden.de>

 a) In the so-called "whole dtor" which calls the dtors of all members
 including the dtor declared (if any). The attributes of the "whole dtor"
 are deduced.

 b) Everything takes place in the dtor declared (if any). If the dtor is
 pure/nothrow/safe, it is guaranteed that the object can be destructed
 purely/without throwing/safely. This will break existing code.

 -----
 struct S { ~this() { } }
 struct SX { S s; pure ~this() { } }
 -----

 a) Compiles.
 b) Error: S.s.~this is impure

 Both behaviors are available on github:
 a) https://github.com/D-**Programming-Language/dmd/pull/**2006<https://github.com/D-Programming-Language/dmd/pull/2006>
 b) https://github.com/D-**Programming-Language/dmd/pull/**2003<https://github.com/D-Programming-Language/dmd/pull/2003>

 You can apply this to postblit, too.
Until 2.062, dmd has been behaved as a) for destructors, but current git head is accidentally changed to b). I think it is a regression. Kenji Hara
May 10 2013