This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

template - excessive recursion



Hi, 

I'm using templates and during compiling i get the error #458 "excessive recursion at instantiation".

It's not a endless recursion; i just need more iterations.

Is there a way to set up the recursion threshold? Has it some deeper meaning?

using compiler TI v7.4.2 

-mv6600 --abi=eabi -O2 -ms2 --symdebug:none --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.4.2/include"  --gcc 

  • How many iterations do you have in this recursion? Other compilers limit this to 512 or so, but I am not sure about the TI compiler in this special case.

  • Mat Sc said:
    Is there a way to set up the recursion threshold?

    Unfortunately, no.  Please send me a test case as described in the last part of the forum guidelines, particularly the part about using preprocessing to boil everything down to one source file.  I'll use that to submit an issue in the SDOWP system.

    Thanks and regards,

    -George

  • Hi, following code highlights my problem.

    Faculty of 64 works fine, 65 results in described error.  

    As Laszlo Papp mentioned, other compilers have a higher default recursion limit. a compiler flag would be great where you can set the depth. like in gcc (-ftemplate-depth-X)

    #include <iostream>
    template <unsigned int x>
    struct Faculty {
    static unsigned int const value = Faculty<x-1>::value*x;
    };
    template <>
    struct Faculty<0> {
    static unsigned int const value = 1;
    };
    int main(void) {
    std::cout << Faculty<65>::value << std::endl; // error
    std::cout << Faculty<64>::value << std::endl; // works
    }

    Thanks, Matthias

  • Thank you for the test case.  With it, I filed SDSCM00046877 in the SDOWP system to request the compiler supply a command line switch which sets the limit on the depth of template instantiations at which the compiler assumes runaway recursion is happening.  Feel free to track this issue with the SDOWP link below in my signature.

    Thanks and regards,

    -George