https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39478

--- Comment #5 from Daniel Frey <d.frey at gmx dot de> ---
I don't know if it is possible for GCC to know, but it feels like it should
know. If one type needs to instantiate another type, this goes on until either
everything worked or GCC stops to instantiate a sub-type because this is
already part of the current "stack" of template instantiations. Maybe I lack
the background to understand what else the compiler could do, but it seems to
me that it must somehow detect where to stop and instead bail out with an
incomplete type which is then triggering the current error message in the
caller which does require the instantiation to be successful.

An error message could therefore look like this IMHO:

t.cc: In instantiation of 'foo<bar<int> >'
t.cc:14:   instantiated from here
foo< bar< int > > x;
                  ^
t.cc:14: error: cyclic instantiation dependency in 'foo<bar<int> >'
t.cc:4:   instantiating 'bar<int>' required for 'foo<bar<int> >'
  typename T::type dummy();
              ^
t.cc:11:   instantiating 'foo<bar<int> >' required for 'bar<int>', end of cycle
  foo< bar > p;
             ^

Reply via email to