http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60605
Bug ID: 60605 Summary: incorrect diagosis of default template argument for function declaration inside class template member function Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: public at alisdairm dot net This bug looks looks obscure, but breaks our 'static assert' facility for C++03 compilers (after applying a workaround for the gcc 4.8 unused typedef warning): template <typename T = int> struct Foo { void bar() { void bug(); } }; This should simply be declaring 'bug' as a function in the enclosing namespace, the default template parameter on the class template is irrelevant, 'bug' is neither a function template nor a member function of a class template. With g++ -std=c++03 I get: main.cpp: In member function 'void Foo<T>::bar()': main.cpp:4:18: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11 void bug(); ^ With g++ -std=c++11 I get: main.cpp: In member function 'void Foo<T>::bar()': main.cpp:4:18: error: default argument for template parameter for class enclosing 'void bug()' void bug(); ^ I am not sure what language rule the C++11 switch thinks it is diagnosing, this code is accepted by the Clang compiler which I used as a cross-check.