This is not wrong-code, this is a performance issue.
*** This issue has been marked as a duplicate of issue 2356 ***
Comment #2 by siegelords_abode — 2012-10-28T12:35:49Z
No, it is not. Issue 2356 does not affect the array in struct A. The bug here is the difference between A and B and not how badly B is implemented. Both cases (or should) involve static array literal initialization, with the bug being that B does not use it.
Comment #3 by clugdbug — 2013-01-31T06:40:49Z
I don't think the code should compile. 'enum' should be declaring a manifest constant, it shouldn't be possible to index it at run time. The whole point of these enum constants was that they shouldn't appear in the executable!
If you want it to appear in the executable, use can use immutable or const.
This is a duplicate of another bug, I forget which one though.
Comment #4 by yebblies — 2013-11-23T22:34:28Z
It looks a little like issue 9953, but it isn't. Because int[8] is a static array, the array literal is a value type and it is valid to store in an enum.
There is no special casing for static array typed array literals, but there should be. They should be created on the stack, then indexed.
https://github.com/D-Programming-Language/dmd/pull/2870
Comment #5 by github-bugzilla — 2013-12-10T07:43:23Z
The bug fix will also improve generated code in following case:
void foo(int[3] sa) {}
void main() { foo([1,2,3]); } // array literal is typed as static array, so
// it won't be allocated on heap.
Comment #8 by github-bugzilla — 2013-12-19T04:24:43Z