This is the mail archive of the gcc-bugs@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]

[Bug c++/25110] New: "expected primary-expression before ')' token" error when compiling templated method of templated class


Hello,

I stumbled across a somewhat strange behaviour in GCC 4.0.2. I was able to
simplify my code down to the following:


template<typename T>
struct Type2Type
{
        typedef T type;
};

template<typename T>
class Foo
{
public:
        template<int i>
        void Func()     { }
};

template<typename T>
void Bar(const T& p1)
{
        Foo<typename Type2Type<T>::type> f;
        f.Func<0>();
}

int main()
{
        Bar(1);
        return 0;
}


I didn't really figure out what exactly is responsible for this behaviour.
However, changing the "typename Type2Type<T>::type" to a simple type, let's say
an int, works. So, replacing
    Foo<typename Type2Type<T>::type> f;
with
    Foo<int> f;
works, but that doesn't help me in my case.

Unfortunately, typedefing the expression, in order to write
    typedef typename Type2Type<T>::type someType;
    Foo<someType> f;
instead of
    Foo<typename Type2Type<T>::type> f;
yields the same error.


The output I get is:
test.cpp: In function 'void Bar(const T&)':
test.cpp:20: error: expected primary-expression before ')' token
test.cpp: In function 'void Bar(const T&) [with T = int]':
test.cpp:26:   instantiated from here
test.cpp:20: error: invalid use of member (did you forget the '&' ?)


I'm using g++ 4.0.2 on Windows using the files over there
http://www.thisiscool.com/gcc_mingw.htm

The command line used:
g++.exe test.cpp -mwindows

I do hope that this is information is useful
Thanks


-- 
           Summary: "expected primary-expression before ')' token" error
                    when compiling templated method of templated class
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lichtwerk dot x at laposte dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25110


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