Bug in Array?
    Frustrated via Digitalmars-d 
    digitalmars-d at puremagic.com
       
    Fri Jul 18 16:37:52 PDT 2014
    
    
  
std.container.Array seems to have a bug in the latest beta. 
emplace fails
         // Insert one item
         size_t insertBack(Stuff)(Stuff stuff)
         if (isImplicitlyConvertible!(Stuff, T))
         {
             if (_capacity == length)
             {
                 reserve(1 + capacity * 3 / 2);
             }
             assert(capacity > length && _payload.ptr);
             emplace(_payload.ptr + _payload.length, stuff);    // 
** fails
             _payload = _payload.ptr[0 .. _payload.length + 1];
             return 1;
         }
forcing the length to be larger works. But the array itself does 
not auto expand like it should.
This happens when the array is a ref property inside a class.
Also, I get an error in emplaceRef trying to access invalid 
memory.
         else
         {
             chunk = arg;
             return chunk;
         }
when trying to insert an element.
Seems Array is broken!!
    
    
More information about the Digitalmars-d
mailing list