http://d.puremagic.com/issues/show_bug.cgi?id=9335


[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
           See Also|                            |http://d.puremagic.com/issu
                   |                            |es/show_bug.cgi?id=9334


--- Comment #1 from [email protected] 2013-01-17 08:39:31 PST ---
(In reply to comment #0)
> Dynamic arrays of structs initialized by array literals go out of scope 
> without
> calling destructors. This does not happen with static arrays.
> 
> import std.stdio : writefln;
> 
> struct S
> {
>     int i;
>     this(this) { writefln("%X postbit", i); i = 0;}
>     ~this() { writefln("%X dtor", i); }
> }
> 
> void main()
> {
>     S[] arr = [S()];
> }
> 
> Issue is maked as dmd issue, because druntime cannot call destructors when AA
> array goes out of the scope.

Same answer as in http://d.puremagic.com/issues/show_bug.cgi?id=9334.

The array is allocated dynamically, and makes no promises it will release at
the end of the scope, or of the program.

I'm not sure what you mean by "array literals", but you'll get the same
behavior with:
S[] arr = new S[](5);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to