https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66686
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to Patrick Palka from comment #2) > (In reply to Martin Sebor from comment #1) > > The code doesn't look valid to me: Y is not a valid template argument for > > the template template parameter C. > > But once "struct X" gets instantiated like in the very last line, doesn't it > become a valid template argument? There, B is set to int, thus the template > parameter C gets the type "template <int> class" which is exactly the type > of the template Y. Err, I meant the parameter Z gets the type "template <int> class" which is exactly the type of the template Y. So it seems that early-rejecting this template definition is too pessimistic because there exist template arguments that make the instantiated code valid.