This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Compiler error w/ templates and default argument value


Hello All,

I've run into this:

----8<----8<----8<----
template<typename F, typename A>
class B
{
protected:
	static const int i = 42;
};

template<typename F, typename A>
class D : protected B<F, A>
{
public:
	D(int n_ = B<F, A>::i); // line 12
};
----8<----8<----8<----

gcc-4.1 and 4.3 give the same error message:

t.cpp:12: error: expected ‘,’ or ‘...’ before ‘>’ token
t.cpp:12: error: wrong number of template arguments (1, should be 2)
t.cpp:2: error: provided for ‘template<class F, class A> class B’
t.cpp:12: error: default argument missing for parameter 2 of ‘D<F, A>::D(int, A)’


If I write D(int n_ = (B<F, A>::i) ), then it compiles. Imho it should compile w/o the extra parentheses. VC++ 2008 Express compiled it. Wanted to test gcc 4.4, too, but I wasn't able to compile the 20081003 snapshot (/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory). I have a debian lenny/amd64 system.

Regards, P
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]