Bug 11664 – A function with a local static variable is unusable in CTFE
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-02T09:34:00Z
Last change time
2013-12-03T16:16:59Z
Keywords
CTFE, pull, rejects-valid
Assigned to
nobody
Creator
samukha
Comments
Comment #0 by samukha — 2013-12-02T09:34:45Z
int foo()
{
static x = 1;
return 0;
}
enum y = foo();
Error: Static variable x cannot be modified at compile time
The static variable is not modified. Equivalent to:
int x_private_to_foo = 1;
int foo()
{
return 0;
}
enum y = foo();