[cfe-dev] recursive template instantiation exceeded maximum depth of 1024

degski via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 16 02:08:21 PDT 2018


On 16 July 2018 at 11:06, Csaba Raduly <rcsaba at gmail.com> wrote:

> You seem to be confusing run-time with compile-time. These errors are
> issued by the compiler while analyzing the source.


 I understand, that it is at compile-time (otherwise it wouldn't be a
problem). My point is, why is there in the case of recursive templates (as
like in the example) a depth-limit at all. I mean at each recursive
instantiation, there should be no need to increase the depth on each
instantiation, as one can "forget" about the ones already instantiated,
"they did not match".

There is no call stack yet.
>

 Well, obviously I know nothing about how it works under the hood (and the
issue is not particular to clang, this is how all c++compilers work), but I
interpreted the fact that there is a depth at all, that there must be some
kind of stack-like mechanism.

Referring to prolog, the compiler/interpreter would translate such a
*tail-recursive
call* (which would fill the prolog-call-stack, if taken at face-value) into
iteration (by re-using the same stack-frame), which allows the "depth" to
be arbitrarily deep (as there is non).

Possibly, I'm expressing myself poorly, my apologies.

degski
-- 
*"If something cannot go on forever, it will stop" - Herbert Stein*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180716/64bc13c3/attachment.html>


More information about the cfe-dev mailing list