CTFE and structs question

Don nospam at nospam.com
Sun Nov 8 08:31:09 PST 2009


g wrote:
> Don Wrote:
> 
>> You can do stuff like:
>>
>> struct Foo {
>>     int x;
>> }
>>
>> enum Foo b = Foo(56);
> 
> strange. you can do that only if there is no constructor.

It also works with opCall. ctor calls don't yet work in CTFE calls from 
module scope (works OK inside a function) -- structural problem with DMD.

> 
> Also trying with templates, i got a segfault, i dont know if it is already reported.
> Why this segfaults?. At least it should print a error message.
> 
> enum Move b = genMove!();
> struct Move{
> 	int Dx;
>     }
> template genMove(){
>     enum invariant(Move) genMove = { Dx:4};
> }
> 
> it just segfaults:

That's new. I've entered it as bug 3488.


More information about the Digitalmars-d-learn mailing list