[Bug c++/17981] New: parse error on template method of template class
fang at csl dot cornell dot edu
gcc-bugzilla@gcc.gnu.org
Wed Oct 13 20:08:00 GMT 2004
----------------------------
gcc/g++ versions (2):
1)
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.3/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-
prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --enable-
languages=c,c++,f77,objc,java,ada --disable-checking --libdir=/usr/lib --enable-
libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-
system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.3 (SuSE Linux)
2)
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1640)
(no more information available from g++ -v on this platform)
-----------------------------------------------
command line:
g++ --save-temps main.cc -o main
------------------------------------------------
compiler output (both versions):
In file included from main.cc:5:
parse-bug.tcc: In member function `ptr<S> foo::func1() const':
parse-bug.tcc:30: error: syntax error before `>' token
------------------------------------------------
remarks:
Apologies if this bug has already been reported,
but I couldn't find it in Bugzilla after 20 minutes of
queries. I've initially flagged this with normal severity,
but it may actually be worse because I cannot find a workaround.
g++-3.4.0 accepts the input below and behaves correctly
in the context of more complicated code.
The input given below is a reduced version that
exhibits the problem.
I've tried a few workarounds such as removing the
explicit template argument, but neither g++3.3.3 nor
3.4.0 accept it, b/c no matching function is found.
I hope a solution is under way.
regards,
David
------------------------------------------------
the preprocessed input file follows:
------------- begin "main.ii" ------------------
# 1 "main.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "main.cc"
# 1 "parse-bug.tcc" 1
# 1 "parse-bug.h" 1
# 12 "parse-bug.h"
template <class T>
class ptr {
private:
T* p;
public:
ptr(T* t) : p(t) { }
~ptr() { }
template <class S>
ptr<S>
is_a_xfer(void) const;
};
class foo {
protected:
ptr<foo> k;
public:
foo() : k(0) { }
template <class T>
ptr<T> func1(void) const;
};
# 9 "parse-bug.tcc" 2
template <class T>
template <class S>
ptr<S>
ptr<T>::is_a_xfer(void) const {
return ptr<S>(dynamic_cast<S*>(p));
}
template <class T>
ptr<T>
foo::func1(void) const {
# 30 "parse-bug.tcc"
return k.is_a_xfer<T>();
}
# 6 "main.cc" 2
int
main (int argc, char* argv[]) {
const foo bar;
ptr<foo> ip = bar.func1<foo>();
return 0;
}
--
Summary: parse error on template method of template class
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fang at csl dot cornell dot edu
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: *
GCC host triplet: *
GCC target triplet: *
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17981
More information about the Gcc-bugs
mailing list