Bug 9941 – [CTFE] Allow to store "newed" classes and structs in the data segment
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-16T13:36:00Z
Last change time
2013-05-17T08:53:58Z
Keywords
CTFE
Assigned to
nobody
Creator
wazar.leollone
Comments
Comment #0 by wazar.leollone — 2013-04-16T13:36:09Z
Allows next code:
class Foo
{
this(int a){f=a;}
int f;
}
static foo = new Foo(42);
Foo constructor can be evaluated at compile-time and static object foo can be placed in static memory.
Comment #1 by bearophile_hugs — 2013-04-16T13:41:24Z
This is currently allowed:
class Foo {
int f;
this(int a) { f = a; }
}
const foo = new Foo(42);
void main() {}
Comment #2 by wazar.leollone — 2013-04-21T12:59:45Z
(In reply to comment #1)
> This is currently allowed:
>
>
> class Foo {
> int f;
> this(int a) { f = a; }
> }
> const foo = new Foo(42);
> void main() {}
Yes:) I was asked to create an issue for this opportunity.