http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485
Bug #: 54485 Summary: g++ should diagnose default arguments in out-of-line definitions for template class member functions Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: dnovi...@gcc.gnu.org CC: ja...@gcc.gnu.org In PR 54484, bootstraps were broken with clang++. The template class vec_t had a member function with default arguments, but the default values were specified in the function definition, instead of its declaration. According to 8.3.6, that's incorrect: "Default arguments for a member function of a class template shall be specified on the initial declaration of the member function within the class template." $ cat a.cc template<typename T> class K { int fn(int, int); }; template<typename T> int K<T>::fn (int a, int b = 3) { return a - b; } $ g++ -c a.cc $ clang++ -c a.cc a.cc:8:26: error: default arguments cannot be added to an out-of-line definition of a member of a class template int K<T>::fn (int a, int b = 3) ^ ~ 1 error generated. $ g++ --version g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ clang++ --version Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)Target: x86_64-pc-linux-gnu Thread model: posix