public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9887: Syntax error on explicit member function template argument in function template body
@ 2003-02-28 14:06 isak
0 siblings, 0 replies; 2+ messages in thread
From: isak @ 2003-02-28 14:06 UTC (permalink / raw)
To: gcc-gnats; +Cc: isak
>Number: 9887
>Category: c++
>Synopsis: Syntax error on explicit member function template argument in function template body
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Fri Feb 28 14:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Isak Johnsson
>Release: GNU C++ version 3.2.3 20030210
>Organization:
>Environment:
Debian GNU/Linux unstable on Intel Celeron machine with 256MB RAM.
>Description:
The type of a member funtion template can't be specified explicitly when called from the context of a funtion template where the class of the member function is a template argument. G++ gives a syntax error.
Preprocessed source:
# 1 "t.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cc"
class A {
public:
template<typename V>
void f() {
}
};
template<typename T>
void g(T x) {
x.f<int>(); // syntax error
}
void h() {
A a;
a.f<int>(); // ok
g(a);
}
Command line: g++ -v -save-temps -c -Wall t.cc
Output:
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.3 20030210 (Debian prerelease)
/usr/lib/gcc-lib/i386-linux/3.2.3/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ t.cc -Wall t.ii
GNU CPP version 3.2.3 20030210 (Debian prerelease) (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/i386-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.2
/usr/include/c++/3.2/i386-linux
/usr/include/c++/3.2/backward
/usr/local/include
/usr/lib/gcc-lib/i386-linux/3.2.3/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i386-linux/3.2.3/cc1plus -fpreprocessed t.ii -quiet -dumpbase t.cc -Wall -version -o t.s
GNU CPP version 3.2.3 20030210 (Debian prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.3 20030210 (Debian prerelease) (i386-linux)
compiled by GNU C version 3.2.3 20030210 (Debian prerelease).
t.cc: In function `void g(T)':
t.cc:10: syntax error before `>' token
>How-To-Repeat:
See description.
>Fix:
This an be used as a workaround:
template<typename T, typename V>
struct X {
static void f(T x) {
x.f<V>();
}
};
template<typename T>
void g2(T x) {
X<T, int>::f(a);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/9887: Syntax error on explicit member function template argument in function template body
@ 2003-03-03 15:17 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-03-03 15:17 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, isak, nobody
Synopsis: Syntax error on explicit member function template argument in function template body
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Mon Mar 3 15:17:04 2003
State-Changed-Why:
Not a bug. You need to write
x.template f<int>(); // syntax error
(note the "template" keyword here).
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9887
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-03 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-28 14:06 c++/9887: Syntax error on explicit member function template argument in function template body isak
2003-03-03 15:17 bangerth
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).