http://d.puremagic.com/issues/show_bug.cgi?id=2559
clugdbug@yahoo.com.au changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |blocker
Keywords| |accepts-invalid
Priority|P2 |P1
Summary|enum doesn't work properly |bad code generation for enum
|for invariant arrays |arrays
------- Comment #1 from clugdbug@yahoo.com.au 2009-04-08 02:08 -------
I've changed the title, since I believe this bug is extremely serious. Simpler example:
--------------
enum ubyte[4] a = [5,6,7,8];
void main()
{
int x=3;
assert(a[x]==7);
}
-----------
Interestingly, compiling with -O gives
bug.d(7): Error: variable a used before set
which shows that the initializer is being ignored.
My opinion is that that's correct -- the only reason you're using an enum is so
that it doesn't appear in the executable! Using a variable to index into the
enum is arguably equivalent to taking the address of the enum, and should
therefore be illegal -- use "immutable" instead.
--