This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40177] New: ADL with non-unqualified-id
- From: "schaub-johannes at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 May 2009 16:36:23 -0000
- Subject: [Bug c++/40177] New: ADL with non-unqualified-id
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hello all, this is a follow-up of #34870 . I tried to compile this one, and GCC
accepts, while it should reject it (it's not valid as #34870 might suggest):
struct A { template<int N> friend void f(A) { } };
int main() { f<1>(A()); }
The friend template function declared within class A is not visible at the
point of call in main. However, for forming an unqualified-id that's a
template-id (which is the only form to fulfill the syntactic requirement of an
unqualified-id), the name used in the template-id must be known as a template
first. Since that's not the case here, and name-lookup is also not delayed to a
point where a declaration of A::f are visible by unqualified-lookup, the
example is ill-formed and should be rejected, since "f<1>" must be parsed as a
relational expression not making sense in this context at all.
The same is true when instead of a non-type parameter a type-parameter is used.
It does not change anything w.r.t the interpretation as a non-unqualified-id.
See the note of the C++ Standard at 14.8.1/6 and section 14.2 (especially
14.2/2).
--
Summary: ADL with non-unqualified-id
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: schaub-johannes at web dot de
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40177