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:
--001a11c2690c708a1604dc5f611d
Content-Type: text/plain; charset=UTF-8

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. Pull#2006 will change back the behavior to a), but pull#2003 doesn't. Kenji Hara --001a11c2690c708a1604dc5f611d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">2013/5/11 Henning Pohl <span dir=3D"ltr">&lt;<a href=3D"ma= ilto:henning still-hidden.de" target=3D"_blank">henning still-hidden.de</a>= &gt;</span><br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><block= quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-w= idth:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding= -left:1ex"> a) In the so-called &quot;whole dtor&quot; which calls the dtors of all mem= bers including the dtor declared (if any). The attributes of the &quot;whol= e dtor&quot; are deduced.<br> <br> b) Everything takes place in the dtor declared (if any). If the dtor is pur= e/nothrow/safe, it is guaranteed that the object can be destructed purely/w= ithout throwing/safely. This will break existing code.<br> <br> -----<br> struct S { ~this() { } }<br> struct SX { S s; pure ~this() { } }<br> -----<br> <br> a) Compiles.<br> b) Error: S.s.~this is impure<br> <br> Both behaviors are available on github:<br> a) <a href=3D"https://github.com/D-Programming-Language/dmd/pull/2006" targ= et=3D"_blank">https://github.com/D-<u></u>Programming-Language/dmd/pull/<u>= </u>2006</a><br> b) <a href=3D"https://github.com/D-Programming-Language/dmd/pull/2003" targ= et=3D"_blank">https://github.com/D-<u></u>Programming-Language/dmd/pull/<u>= </u>2003</a><br> <br> You can apply this to postblit, too.<br> </blockquote></div><br></div><div class=3D"gmail_extra">Until 2.062, dmd ha= s been behaved as a) for destructors, but current git head is accidentally = changed to b).</div><div class=3D"gmail_extra" style>I think it is a regres= sion.<br> </div><div class=3D"gmail_extra" style><br></div><div class=3D"gmail_extra"= style>Pull#2006 will change back the behavior to a), but pull#2003 doesn&#= 39;t.</div><div class=3D"gmail_extra" style><br></div><div class=3D"gmail_e= xtra" style> Kenji Hara</div></div> --001a11c2690c708a1604dc5f611d--
May 10 2013