Debugging CTFE

Ary Borenszweig ary at
Tue Jun 17 17:18:26 PDT 2008

Jarrett Billingsley a écrit :
> "Matthias Walter" <Matthias.Walter at> wrote in message 
> news:g38na9$2gs7$1 at
>> Hello,
>> I have written some compile time executable functions with D 1.0 which 
>> work in runtime but hang (and allocate memory without end) at 
>> compile-time. Is there a way to debug this further? Can one print stuff 
>> out? (Don't know if writefln works at compile-time, as I'm using Tango) 
>> Can I somehow get a stack trace of the functions called?
> No, no, and no.  CTFE support in the current frontend has some rather 
> unworkable disadvantages.  For one, it's terribly buggy.  You're better off 
> trying to convert it to templates in most cases.  For two, CTFE is 
> interpreting a garbage-collected language but is not itself 
> garbage-collected, meaning that memory-unconscious code evaluated at compile 
> time (i.e. a loop that appends data to the end of a string) will just leak 
> like hell and cause the compiler to easily use up several GB of memory. 
> That might be what's happening to your code.  Or it could be a bug in CTFE. 

After I finish making Descent support D2, I'll try to make templates and 
CTFE debuggable (i.e. you put a breakpoint, you right click on a 
template or a function and select "Debug at compile-time"). The 
advantage here is, it's java code, so the intepreted code does get 
garbage collected. ;-)

I don't think it's hard to do, all the information is available in the 
front-end for this. Of course, any help will be appreciated.

More information about the Digitalmars-d-learn mailing list