D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2361 - delete is allowed on invariant references.
Summary: delete is allowed on invariant references.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, patch
Depends on:
Blocks: 2573
  Show dependency treegraph
 
Reported: 2008-09-16 09:14 UTC by Dave
Modified: 2015-06-09 01:20 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dave 2008-09-16 09:14:51 UTC
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;
}