Bug 15201 - Parsing Problem with template (with > 1type) as default parameter
Summary: Parsing Problem with template (with > 1type) as default parameter
Status: RESOLVED DUPLICATE of bug 57
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-29 12:54 UTC by Uwe Arzt
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Testprogram (361 bytes, text/plain)
2004-04-29 12:58 UTC, Uwe Arzt
Details
Output with g++ -v (814 bytes, text/plain)
2004-04-29 13:00 UTC, Uwe Arzt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Arzt 2004-04-29 12:54:25 UTC
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
Comment 1 Uwe Arzt 2004-04-29 12:58:29 UTC
Created attachment 6186 [details]
Testprogram
Comment 2 Uwe Arzt 2004-04-29 13:00:47 UTC
Created attachment 6187 [details]
Output with  g++ -v
Comment 3 Wolfgang Bangerth 2004-04-29 14:22:47 UTC
This is a duplicate of one of our very (very very) old bug reports, 
PR 57. 
 
W. 

*** This bug has been marked as a duplicate of 57 ***