AA ignores disabling of postblit for key types

Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 21 05:18:28 PDT 2016


The following code


import std.stdio;

struct S(E)
{
     static typeof(this) withElement(E x)
     {
         typeof(return) that;
         that._ptr = cast(E*)malloc(1*E.sizeof);
         *(that._ptr) = x;
         return that;
     }

     // @disable this(this);
     this(this) { assert(false); }

     ~this()
     {
         writeln("freeing:", _ptr);
         free(_ptr);
     }

     E* _ptr;
}

unittest
{
     alias Key = S!int;
     int[Key] x;
     writeln("before");
     x[Key.withElement(11)] = 42;
     writeln("after");
}

extern (C):
void* malloc(size_t);
void free(void*);


assert as


before
freeing:706490
core.exception.AssertError at aaNoMoveCrash.d(18): Assertion failure
----------------
??:? [0x411a3f]
??:? [0x41028f]
aaNoMoveCrash.d:18 [0x402b73]
??:? [0x413be5]
??:? [0x4126a8]
aaNoMoveCrash.d:34 [0x402a46]
??:? [0x410230]
??:? [0x41c8a0]
??:? [0x4113cb]
??:? [0x4162e6]
??:? [0x416374]
??:? [0x416277]
??:? [0x4113a7]
??:? [0x41c792]
??:? [0x412dfa]
??:? [0x412d98]
??:? [0x412d12]
??:? [0x4103bf]
??:? __libc_start_main [0x8452a82f]
freeing:706490


It seems AA's doesn't respect disabling of postblit for its 
Key-type even when it's sent as an r-value.

This is a serious bug.

Is this know?

Can somebody give hints to where I can start digging in DMD for 
fixing this?


More information about the Digitalmars-d mailing list