We encountered that gcc fails to compile with a parse error if a template based function argument is assigned a default initializer in the function prototype. Here is a stand alone test case for the exact problem: #define BUG template<typename A, typename B> struct C {}; typedef C<int, int> C_int_int; int w_typedef(C<int,int> arg = C_int_int()) { return 0; } int wo_typedef(C<int,int> arg = C<int,int>()) { return 0; } struct S { int w_typedef(C_int_int arg = C_int_int()) { return 0; } #ifdef BUG int wo_typedef(C<int, int> arg = C<int,int>()) { return 0; } #endif }; int main(int argc, char* argv[]) { w_typedef(); wo_typedef(); S s; s.w_typedef(); #ifdef BUG s.wo_typedef(); #endif return 0; } It compiles fine when BUG is not defined though. This code failed with gcc 3.2.2, 3.3.3 and also with 3.4, using various distributions (e.g. Debian and RedHat).
This is a dup of bug 57, one of the oldest bugs in GCC which is suspended because there is a DR report about the problem and no can agrue of what the standard says. A simple workaround is to do: int wo_typedef(C<int, int> arg = (C<int,int>())) note the parentheses around the default argument. *** This bug has been marked as a duplicate of 57 ***
Does it? Trying your proposed workaround gives me a "parse error before `;' token" (currently tested with gcc 3.2.2).
oh, the workaround only works on 3.4.0 and above then.