[Issue 9386] struct destructor called erroneously

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 24 08:21:40 PST 2013


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


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim at maxim-fomin.ru


--- Comment #2 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-01-24 08:21:27 PST ---
The problem is that dmd lowers the code to like below:

void main()
{
   Test _temp1;
   Test _temp2;
   Test _temp3;
   Test _temp4;
   Test[] tests = [ Test(), Test(), Test(), Test() ]; //these ctors are not
called
   _temp1.ctor("one"); 
   tests[0] = _temp1;
   _temp2.ctor("two");
   tests[1] = _temp2;
   _temp3.ctor("three");
   tests[2] = _temp3;
   _temp4.ctor("four");
   tests[3] = _temp4;
   _temp1.dtor();
   _temp2.dtor();
   _temp3.dtor();
   _temp4.dtor();
   ...
}

So, the first 8 lines of output comes from 4 stack temporaries, not array.
Perhaps you need to look at issue 9335 and issue 9334

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


More information about the Digitalmars-d-bugs mailing list