[Issue 2361] New: delete is allowed on invariant references.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 16 07:14:52 PDT 2008


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 at digitalmars.com
        ReportedBy: godaves at 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;
}


-- 



More information about the Digitalmars-d-bugs mailing list