http://d.puremagic.com/issues/show_bug.cgi?id=9335
--- Comment #2 from Maxim Fomin <[email protected]> 2013-01-17 10:07:54 PST --- (In reply to comment #1) > 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); Well, situation here is different than in issue 9334 import core.stdc.stdio : printf; struct S { int i; this(this) { printf("%X postbit\n", i); i = 0;} ~this() { printf("%X dtor\n", i); } } void main() { S[] arr = [S()]; } Dump of assembler code for function _Dmain: 0x0000000000418894 <+0>: push %rbp 0x0000000000418895 <+1>: mov %rsp,%rbp 0x0000000000418898 <+4>: sub $0x10,%rsp 0x000000000041889c <+8>: movabs $0x1,%rsi 0x00000000004188a6 <+18>: movabs $0x6362a0,%rdi 0x00000000004188b0 <+28>: callq 0x41a610 <_d_arrayliteralTX> 0x00000000004188b5 <+33>: xor %ecx,%ecx 0x00000000004188b7 <+35>: mov %ecx,-0x8(%rbp) 0x00000000004188ba <+38>: lea -0x8(%rbp),%rsi 0x00000000004188be <+42>: mov %rax,%rdi 0x00000000004188c1 <+45>: movsb %ds:(%rsi),%es:(%rdi) 0x00000000004188c2 <+46>: movsb %ds:(%rsi),%es:(%rdi) 0x00000000004188c3 <+47>: movsb %ds:(%rsi),%es:(%rdi) 0x00000000004188c4 <+48>: movsb %ds:(%rsi),%es:(%rdi) 0x00000000004188c5 <+49>: mov %rax,%rdx 0x00000000004188c8 <+52>: movabs $0x1,%rax 0x00000000004188d2 <+62>: mov %rcx,%rax 0x00000000004188d5 <+65>: leaveq 0x00000000004188d6 <+66>: retq End of assembler dump. Array literal is allocated by _d_arrayliteralTX, yet is initialized by a stack temporary S(). Where a dtor call on it? The behavior is in contrast to issue 9334 when a dtor in similar situation is called. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
