#include <iostream> template <class T> class X { /* ... */ }; void f() { struct S { /* ... */ }; X<S> x3; // error: local type used as template-argument X<S*> x4; // error: pointer to local type used as template-argument } int main() { f(); return 0; }
Standard input is empty
prog.cpp: In function ‘void f()’: prog.cpp:8:6: error: template argument for ‘template<class T> class X’ uses local type ‘f()::S’ X<S> x3; // error: local type used as template-argument ^ prog.cpp:8:6: error: trying to instantiate ‘template<class T> class X’ prog.cpp:8:10: error: invalid type in declaration before ‘;’ token X<S> x3; // error: local type used as template-argument ^ prog.cpp:9:7: error: template argument for ‘template<class T> class X’ uses local type ‘f()::S*’ X<S*> x4; // error: pointer to local type used as template-argument ^ prog.cpp:9:7: error: trying to instantiate ‘template<class T> class X’ prog.cpp:9:11: error: invalid type in declaration before ‘;’ token X<S*> x4; // error: pointer to local type used as template-argument ^ prog.cpp:8:8: warning: unused variable ‘x3’ [-Wunused-variable] X<S> x3; // error: local type used as template-argument ^ prog.cpp:9:9: warning: unused variable ‘x4’ [-Wunused-variable] X<S*> x4; // error: pointer to local type used as template-argument ^
Standard output is empty