c++/9460: parse error on template member function

oliver.schoenborn@utoronto.ca oliver.schoenborn@utoronto.ca
Mon Jan 27 19:55:00 GMT 2003


>Number:         9460
>Category:       c++
>Synopsis:       parse error on template member function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 27 19:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Oliver Schoenborn
>Release:        3.2.2 on cygwin, 3.2 linux, 3.0.4 SGI
>Organization:
>Environment:
Cygwin (latest), linux redhat 7.3, SGI Irix 6.5.13
>Description:
struct Test
{
    template <typename T>
    void test(T*) {}
};

template <typename ObjType>
struct Foo
{
    Test _state;
    int _i;
    
    void reset()
    {
        _state.test(&_i); // ok
        _state.test<ObjType>(&_i); // parse error here if...
    }
    
    // ... and only if following is not 
    // same name as Test::test!!!!
    template <typename TT>
    void test2() {}
};
    
int main()
{
    Foo<int> test;
    test.reset();
}

>How-To-Repeat:
Just try to compile the file with "g++ -c file.cc"
>Fix:
none except hack: add extra parameters to function so it can deduce template parameter

Colleague has reported that these may work too (not tested rigorously):
_state.template test<ObjType>(&_i); //avoids the error
_state.Test::test<ObjType>(&_i); //avoids the error


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list