June 02, 2008 [Issue 2139] New: Compiler rejects delegate of a static struct instance as non-constant | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2139 Summary: Compiler rejects delegate of a static struct instance as non-constant Product: D Version: 1.027 Platform: PC OS/Version: Windows Status: NEW Severity: minor Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: jarrett.billingsley@gmail.com The following works. ---------------------------- struct S { static S s; } const foo = &S.s; ---------------------------- The following also works. ---------------------------- void f() {} const bar = &f; ---------------------------- The following, however, does not: ---------------------------- struct S { static S s; void f() {} } // error, non-constant expression S.s.f const baz = &S.s.f; ---------------------------- The compiler should be able to initialize baz at compile time, since baz is composed of the address of a statically-allocated struct and the address of a non-virtual function. -- |
Copyright © 1999-2021 by the D Language Foundation