Debugging CTFE
Don
nospam at nospam.com.au
Thu Jun 19 02:40:56 PDT 2008
Jarrett Billingsley wrote:
> "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.
I disagree. I've not had much trouble with CTFE. The really, really nice
thing about CTFE is that you can write it as a runtime function, and
make sure it works before using it a compile time.
The problem with CTFE is bugzilla issue #1382 (no memory release for
CTFE functions)...
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.
That's very likely. The maximum size of code you can write with CTFE is
pretty small.
> Or it could be a bug in CTFE.
Bugzilla issue #1382 is the killer. One of the most important bugs in
bugzilla, I reckon.
More information about the Digitalmars-d-learn
mailing list