[Issue 6178] Struct inside the AA are not init correctly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 19 12:50:26 PDT 2011


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



--- Comment #1 from Jose Garcia <jsancio at gmail.com> 2011-06-19 12:45:41 PDT ---
Err -- Hit submit without a description...

I am going to assume that this was not already filed. If so please accept my
apologies.

If you create an AA that points to a struct the is not initialized properly. In
other word it is not the same as S.init. If this stays that way in can
completely confuse the dtor. For example:

import std.stdio;

struct Bug
{
   this(this) { writefln("%s postblit ctor called", var); }
   void opAssign(Bug rhs) { writefln("%s opAssign called", var); }
   ~this() { writefln("%s dtor called", var); }

   int var = 0;
}

void main()
{
   Bug[int] map;
   {
      map[0] = Bug(1);
   }
}

This yields the following output (you need -O or you will hit bug 6177):

dmd -w -O map_test.d && ./map_test
3 opAssign called
1 dtor called
3 dtor called

Where in the world is 3 coming from? You output may be slightly different.

-- 
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