This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52529] Compiler rejects template code inconsistently
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 08 Mar 2012 08:50:59 +0000
- Subject: [Bug c++/52529] Compiler rejects template code inconsistently
- Auto-submitted: auto-generated
- References: <bug-52529-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52529
--- Comment #3 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2012-03-08 08:50:59 UTC ---
The compiler is correct to reject your example FIRST, SECOND, and THIRD.
In FIRST and THIRD you are effectively asking to deduce T from
template <typename T> long foo(typename T::X *x);
which is not possible in the general case, we have a so-called non-deduced
context here.
In SECOND you fixed the problem of FIRST correctly, but now you have the
problem that A<M> is a dependent context. This means, that the compiler has to
guess on the meaning of "<T" (It cannot safely assume that this is a function
template). In this situation you are required to insert the "template" keyword
to clarify the situation. Put it all together, the proper syntax would be
A<M>().template foo<T>(x);
Thus, this issue should be declared as invalid.