This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
c++0x: member template fails with a strange error (4.5.1)
- From: Edward PieÅkowski <edek dot pienkowski at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 28 Sep 2010 22:11:54 +0200
- Subject: c++0x: member template fails with a strange error (4.5.1)
Hello,
I have a problem with getting member template resolution right, using gcc 4.5.1.
Is this a bug, or is it some standard quirk? (or maybe I just managed
to miscompile gcc, though bootstrap was done)
This is fine:
----------------------------------------------------------------------------------------------------------------------
#include <memory>
class AA {
public:
template <class T> void doSomething () {};
};
class CC {};
class BB {
std::shared_ptr<AA> a_ptr;
public:
void something () {
this->a_ptr->doSomething<CC> (); // OK
a_ptr->doSomething<CC> (); // OK
AA().doSomething<CC> (); // OK
}
};
---------------------------------------------------------------------------------------------------------------------
This fails in one case: (bug2.h)
----------------------------------------------------------------------------------------------------------
#include <memory>
class AA {
public:
template <class T> void doSomething () {};
};
class CC {};
template <class T> // THIS LINE ADDED
class BB {
std::shared_ptr<AA> a_ptr;
public:
void something () {
this->a_ptr->doSomething<CC> (); // FAILS
a_ptr->doSomething<CC> (); // OK
AA().doSomething<CC> (); // OK
}
};
------------------------------------------------------------------------------------------------------------------
It fails with the following:
21:59:30 (1) $ g++ -std=c++0x -o bug.o bug.cpp
In file included from bug.cpp:1:0:
bug2.h: In member function 'void BB<T>::something()':
bug2.h:16:35: error: expected primary-expression before '>' token
bug2.h:16:38: error: expected primary-expression before ')' token
gcc -v
21:59:48 (1) $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/m1ch/soft/inst/libexec/gcc/x86_64-unknown-linux-gnu/4.5.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../src/gcc-4.5.1/configure
--prefix=/home/m1ch/soft/inst --program-suffix=4.1.5-1 --enable-lto
--enable-bootstrap --with-ppl=/home/m1ch/soft/inst
--with-cloog=/home/m1ch/soft/inst --with-mpc=/home/m1ch/soft/inst
--with-gmp=/home/m1ch/soft/inst --with-mpfr=/home/m1ch/soft/inst
Thread model: posix
gcc version 4.5.1 (GCC)
Edek
Sorry if this mail got twice