https://issues.dlang.org/show_bug.cgi?id=23375
Issue ID: 23375
Summary: enum is not considered global mutable state
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
An enum of slice of class can be mutated and it can be mutated even in a `pure`
function.
Example:
class C
{
string s;
this(string a) pure @safe nothrow { s = a; }
}
enum C[] cs = [ new C("a"), new C("b") ];
void f() pure @safe @nogc nothrow
{
cs[0].s = "c";
}
--