[Issue 2139] New: Compiler rejects delegate of a static struct instance as non-constant
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 2 14:26:16 PDT 2008
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 at digitalmars.com
ReportedBy: jarrett.billingsley at 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.
--
More information about the Digitalmars-d-bugs
mailing list