This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29942] New: Template parameter refused as a template parameter.
- From: "samuel dot hangouet at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Nov 2006 15:13:43 -0000
- Subject: [Bug c++/29942] New: Template parameter refused as a template parameter.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code produce a compilation error at the unique line of the
function named "visit" below (it is a basic implementation of a visitor
pattern) :
# 1 "test.cpp"
# 1 "<interne>"
# 1 "<ligne de commande>"
# 1 "test.cpp"
template <typename T>
struct Toto
{
template <typename T2>
void visit(T2 * o)
{
o->eval<T>();
}
};
template <typename T>
struct Titi
{
template <typename T2>
void eval()
{ }
};
int main()
{
Toto<int> toto;
Titi<int> titi;
toto.visit(& titi);
return 0;
}
g++ test.cpp -o test
test.cpp: In member function «void Toto<T>::visit(T2*)»:
test.cpp:7: erreur: expected primary-expression before «>» token
test.cpp:7: erreur: expected primary-expression before «)» token
make: *** [test] Erreur 1
I tried this with g++-3.4.6 too (it compiles and run well with msvc 8.0).
Here is the output of the command "g++ -v -save-temps test.cpp" :
Utilisation des specs internes.
Cible : i486-linux-gnu
Configuré avec: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk-default --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
--disable-werror --with-tune=pentium4 --enable-checking=release i486-linux-gnu
Modèle de thread: posix
version gcc 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
/usr/lib/gcc/i486-linux-gnu/4.0.3/cc1plus -E -quiet -v -D_GNU_SOURCE test.cpp
-mtune=pentium4 -fpch-preprocess -o test.ii
le répertoire « /usr/local/include/i486-linux-gnu » est ignoré car inexistant
le répertoire « /usr/include/i486-linux-gnu » est ignoré car inexistant
la recherche pour #include "..." débute ici :
la recherche pour #include <...> débute ici:
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3/i486-linux-gnu
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.0.3/include
/usr/include
Fin de la liste de recherche.
/usr/lib/gcc/i486-linux-gnu/4.0.3/cc1plus -fpreprocessed test.ii -quiet
-dumpbase test.cpp -mtune=pentium4 -auxbase test -version -o test.s
GNU C++ version 4.0.3 (Ubuntu 4.0.3-1ubuntu5) (i486-linux-gnu)
compiled by GNU C version 4.0.3 (Ubuntu 4.0.3-1ubuntu5).
heuristiques GGC: --param ggc-min-expand=64 --param ggc-min-heapsize=64420
test.cpp: In member function «void Toto<T>::visit(T2*)»:
test.cpp:7: erreur: expected primary-expression before «>» token
test.cpp:7: erreur: expected primary-expression before «)» token
--
Summary: Template parameter refused as a template parameter.
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: samuel dot hangouet at free dot fr
GCC host triplet: Ubuntu 4.0.3-1ubuntu5
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29942