Debugging CTFE
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Jun 17 09:22:04 PDT 2008
"Matthias Walter" <Matthias.Walter at st.ovgu.de> wrote in message
news:g38na9$2gs7$1 at digitalmars.com...
> 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.
More information about the Digitalmars-d-learn
mailing list