Bug 11697 – Cannot initialize enum with class or pointer to struct.

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-06T12:57:55Z
Last change time
2024-12-13T18:14:56Z
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#18733 →

Comments

Comment #0 by samukha — 2013-12-06T12:57:55Z
class A { int x = 1; } enum a = new A; static assert(a.x == 1); Error: Unable to initialize enum with class or pointer to struct. Use static const variable instead. The limitation is annoying as it has to be sidestepped by wrapping the reference in a struct. Compiles: struct S { A a; } enum s = S(new A); static assert(s.a.x == 1);
Comment #1 by robert.schadek — 2024-12-13T18:14:56Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18733 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB