This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14383] New: Class member incorrectly treated as template-name in function template
- From: "timb at bluearc dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Mar 2004 13:52:01 -0000
- Subject: [Bug c++/14383] New: Class member incorrectly treated as template-name in function template
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Feed this snippet to gcc -c :
----- test.cpp
struct t;
struct A
{
int t;
};
template <typename> void f(A a)
{
a.t < 0;
}
-----
It says:
test.cpp: In function `void f(A)':
test.cpp:10: error: parse error before `;' token
It seems to be taking a.t to be a template name, and therefore < as the start
of a template argument list instead of less-than. a.t is not a template
(whether or not there is also a struct t), so this is wrong. The problem does
not appear if f is not itself templated.
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.3 (Debian)
--
Summary: Class member incorrectly treated as template-name in
function template
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: timb at bluearc dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14383