Segfault when using SysTime

Don nospam at nospam.com
Fri Nov 4 11:04:57 PDT 2011


On 04.11.2011 18:27, Jonathan M Davis wrote:
> On Friday, November 04, 2011 06:07 bearophile wrote:
>> Jonathan M Davis:
>>> and since CTFE can't handle classes - let alone one which is
>>> initialized at compile time and then used at runtime
>>
>> I think CTFE will handle classes in the next DMD version (and in the
>> current GitHub one).
>
> But it's not just a question of handling classes. It has to handle the case
> where the class persists during runtime. From what Don has said in the past,
> I'm pretty sure that supporting classes in CTFE is going to translate to being
> able to use functions that use classes but that none of the classes created
> will be able to be assigned to any variables which persist beyond compilation.
> It needs to become possible to do something like
>
> static immutable _localTime = new immutable(LocalTime)();
>
> For SysTime.init to be valid, LocalTime's instance must be created at compile
> time and persist beyond compilation, and then SysTime's _timezone member
> variable needs to be initialized to it - which would also persist beyond
> compilation.
>
> If Don manages to make that work, that's fantastic, but there's a definite
> difference between being able to use classes with CTFE and initialize member
> and static variables with classes using CTFE, and it is my understanding that
> that we're only getting to use classes in CTFE, not persist them. But maybe
> we're lucky, and I'm wrong about that.
>
> - Jonathan M Davis

That's right. The next release will support classes (and exceptions) in 
CTFE, but as you say, it cannot pass them to run time. This is an issue 
of the glue layer in the compiler.
I do know how it could be done. It will happen eventually, but not soon.



More information about the Digitalmars-d mailing list