I have written a template metaprogramming implementation of an imperative programming language so that you can write "programs" with while loops and destructive assignment which are executed at compile time*. This places a great strain on the C++ compiler, as you might imagine, but the Comeau compiler which I use proved up to the job. Until I got it right I would get some pretty incomprehensible error messages (template metaprogramming is notorious for this).

However, these error messages were nothing to what I got once the program was working. I wrote a "program" in the embedded language to find prime numbers and it worked well (if slowly) for small cases, such as finding all prime numbers below 20. However, when I tried to find the prime numbers up to 50 the compilation showed no signs of stopping. After a couple of hours I killed the compilation task and looked at the output, which I had redirected to a file.

The file was over 500 Mb in size - it had filled the remaining space on my disc so it would probably have been even larger if I'd had more space. The error message indicated that the compiler had run out of memory and it then listed in detail the template instantiation which it had created so far: the textual representation of this instantiation took up most of the 500 Mb.

* See impl at typeshift.org if you're interested in this

Log in or registerto write something here or to contact authors.