[Bug c++/15201] New: Parsing Problem with template (with > 1type) as default parameter
uwe dot arzt at robots dot de
gcc-bugzilla@gcc.gnu.org
Thu Apr 29 14:07:00 GMT 2004
Hi,
// Bug: default Parameter with a template-Type does not work with more than 1
template parameter
#include <stdio.h>
template <typename _type> class A
{
_type local;
public:
A(_type val) { local=val; printf("A\n"); }
};
template <typename _type, typename _type1> class B
{
_type local;
public:
B(_type val) { local=val; printf("B\n"); }
};
template<typename _type, typename _type1> class C
{
public:
C() { printf("C\n"); }
void proc1(A<_type> par = A<_type>(42)) {}; // works
// doesnt't work --> compile error
#ifdef CASE1
void proc2(B<_type, _type1> par = B<_type, _type1>(42)) {};
#endif
// works
#ifdef CASE2
typedef B<_type, _type1> yyy;
void proc2(B<_type, _type1> par = yyy(42)) {};
#endif
};
main()
{
C<int, int> c;
c.proc1();
c.proc2();
}
results in compiler output:
CASE1:
arzt@dbnu003{~/g++} /opt/gcc-3.4/bin/g++ -DCASE1 test1.cpp
test1.cpp:25: error: expected `,' or `...' before '>' token
test1.cpp:25: error: missing `>' to terminate the template argument list
test1.cpp:25: error: wrong number of template arguments (1, should be 2)
test1.cpp:12: error: provided for `template<class _type, class _type1> class B'
test1.cpp: In function `int main()':
test1.cpp:38: error: no matching function for call to `C<int, int>::proc2()'
test1.cpp:25: note: candidates are: void C<_type, _type1>::proc2(B<_type,
_type1>, _type1) [with _type = int, _type1 = int]
CASE2:
arzt@dbnu003{~/g++} /opt/gcc-3.4/bin/g++ -DCASE2 test1.cpp
arzt@dbnu003{~/g++} ./a.out
C
A
B
I think both codes sequences are correct and should behave identical.
Same Problem with g++ 3.3.3.
The following compilers work correctly: SunWorkshop 8, HP Tru64 CXX 6.5, MS
Visual C++ 6.0 SP5
Thanks
Uwe
--
Summary: Parsing Problem with template (with > 1type) as default
parameter
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uwe dot arzt at robots dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15201
More information about the Gcc-bugs
mailing list