www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2361] New: delete is allowed on invariant references.

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

           Summary: delete is allowed on invariant references.
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: godaves yahoo.com


import std.stdio;

void main()
{
    C c = new C(100);
    writefln(c.arr);
    writefln("----");
    writefln(gar);
    writefln("----");
    delete c.arr;
    delete gar;
    writefln(c.arr);
    writefln("----");
    writefln(gar);
}

class C
{
    invariant int[] arr;
    this(size_t sz)
    {
        arr = cast(invariant int[])new int[sz];
        for(size_t i = 0; i < sz; i++) cast(int)arr[i] = i;
    }
}

const sz = 100;
invariant int[] gar;
static this()
{
    gar = cast(invariant int[])new int[sz];
    for(size_t i = 0; i < sz; i++) cast(int)gar[i] = i;
}


-- 
Sep 16 2008