public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29942] New: Template parameter refused as a template parameter.
@ 2006-11-22 15:13 samuel dot hangouet at free dot fr
2006-11-22 16:47 ` [Bug c++/29942] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: samuel dot hangouet at free dot fr @ 2006-11-22 15:13 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/29942] Template parameter refused as a template parameter.
2006-11-22 15:13 [Bug c++/29942] New: Template parameter refused as a template parameter samuel dot hangouet at free dot fr
@ 2006-11-22 16:47 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-11-22 16:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-11-22 16:47 -------
Instead of:
o->eval<T>();
You want:
o->template eval<T>();
Which is required by the C++ standard.
read:
http://gcc.gnu.org/gcc-3.4/changes.html
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29942
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-11-22 16:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-22 15:13 [Bug c++/29942] New: Template parameter refused as a template parameter samuel dot hangouet at free dot fr
2006-11-22 16:47 ` [Bug c++/29942] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).