Wired things happen with g++-3.3.5

P

PengYu.UT

The following gives an error at line 20. However, if I change all
"doit1" to "doit". I will only get warnings. Is there any thing wrong
with gcc?

g++-3.3 -g -Wall -W -I/usr/local/include/clapack/ -c -o main.o main.cc
main.cc: In member function `void C::doit1(typename A<T>::iterator*)':
main.cc:20: error: parse error before `;' token
main.cc: In function `int main(int, char**)':
main.cc:25: warning: unused parameter `int argc'
main.cc:25: warning: unused parameter `char**argv'
make: *** [main.o] Error 1
/////////////////////

template <typename T>
class A {
public:
class iterator{
};
};

class B {
public:
template <typename T>
void doit(typename A<T>::iterator *it){
}
};

class C {
public:
template <typename T>
void doit1(typename A<T>::iterator *it){
B b;
b.doit<T>(it);//line 20
}
};

int main(int argc, char *argv[])
{
A<int>::iterator it1;
C c;
c.doit1<int>(&it1);
}
 
R

red floyd

The following gives an error at line 20. However, if I change all
"doit1" to "doit". I will only get warnings. Is there any thing wrong
with gcc?

g++-3.3 -g -Wall -W -I/usr/local/include/clapack/ -c -o main.o main.cc
main.cc: In member function `void C::doit1(typename A<T>::iterator*)':
main.cc:20: error: parse error before `;' token
main.cc: In function `int main(int, char**)':
main.cc:25: warning: unused parameter `int argc'
main.cc:25: warning: unused parameter `char**argv'
make: *** [main.o] Error 1
/////////////////////

template <typename T>
class A {
public:
class iterator{
};
};

class B {
public:
template <typename T>
void doit(typename A<T>::iterator *it){
}
};

class C {
public:
template <typename T>
void doit1(typename A<T>::iterator *it){
B b;
b.doit<T>(it);//line 20
}
};

int main(int argc, char *argv[])
{
A<int>::iterator it1;
C c;
c.doit1<int>(&it1);
}

Comeau online seems to like it. Cross posting to gnu.g++.help
 
I

Ian

The following gives an error at line 20. However, if I change all
"doit1" to "doit". I will only get warnings. Is there any thing wrong
with gcc?
I see neither errors nor warning with gcc 3.4.2.

Ian
 
B

Branimir Maksimovic

The following gives an error at line 20. However, if I change all
"doit1" to "doit". I will only get warnings. Is there any thing wrong
with gcc?

g++-3.3 -g -Wall -W -I/usr/local/include/clapack/ -c -o main.o main.cc
main.cc: In member function `void C::doit1(typename A<T>::iterator*)':
main.cc:20: error: parse error before `;' token .....
class B {
public:
template <typename T>
void doit(typename A<T>::iterator *it){
}
};

class C {
public:
template <typename T>
void doit1(typename A<T>::iterator *it){
B b;
b.doit<T>(it);//line 20

try with
b.template doit<T>(it);
Perhaps gcc 3.3 can't figure out that doit is template function,
but 3.4.2 compiles ok.

Greetings, Bane.
 
P

Paul Pluzhnikov

red floyd said:
(e-mail address removed) wrote:

Comeau online seems to like it. Cross posting to gnu.g++.help

g++ 3.4.0, 3.4.3 and 4.0.0 also accept this.
Looks like a bug that has been fixed.

Cheers,
 
P

PengYu.UT

Branimir said:
try with
b.template doit<T>(it);
Perhaps gcc 3.3 can't figure out that doit is template function,
but 3.4.2 compiles ok.


Greetings, Bane.

It is as you pointed out.

Is this form of envoking template member function "b.template
doit<T>(it);" in the C++ Standard?

Is it actually a bug of gcc 3.3?
 
B

Branimir Maksimovic

It is as you pointed out.

Is this form of envoking template member function "b.template
doit<T>(it);" in the C++ Standard?

It is described in 5.2 postfix expressions.
Is it actually a bug of gcc 3.3?

Standard says this is optional, not mandatory, so it could be bug, but I'm
not really
sure.

Greetings, Bane.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top