Recursive template instantiation

Yury Usishchev jolfzverb@gmail.com
Mon Mar 31 12:27:00 GMT 2014


Hello!

I have a question about test case in pr60687:

template <typename CALLER>
void exec1(CALLER & caller) {
  struct Me : public CALLER {
  public:
    Me(CALLER & caller) : CALLER(caller) {};
    void exec() {
      if(0) exec1(*this);
    }
  } me(caller);
  return me.exec();
}

int main(int, char**) {
  struct Me0 {} me;
  exec1(me);
  return 0;
}

Currently gcc fails to compile it with 'template
instantiation depth exceeds maximum' error

But actually exec1 is not recursive, so we dont need
to instantiate all these templates.

So the question is:
  Is this behavior valid? Or maybe according to C++11
standard we should be able to compile and run such code.


-- 
BR,
Usishchev Yury



More information about the Gcc-help mailing list