Assigning a static array

Brad Anderson eco at gnuk.net
Thu Apr 18 14:06:32 PDT 2013


Is this supposed to be allowed:

ubyte[] a;
ubyte[16] b;
a = b;
assert(a.ptr == b.ptr);

Because if so that makes it terribly easy to do a bug like this 
(as I just saw in IRC):

struct A
{
     ubyte[] a;
     this(ubyte c)
     {
         ubyte[16] b;
         b[] = c;
         this.a = b;  // a now points at an immediately invalid 
static array
     }
}


More information about the Digitalmars-d-learn mailing list