public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40177]  New: ADL with non-unqualified-id
@ 2009-05-17 16:36 schaub-johannes at web dot de
  2009-11-05 22:11 ` [Bug c++/40177] " jason at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: schaub-johannes at web dot de @ 2009-05-17 16:36 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/40177] ADL with non-unqualified-id
  2009-05-17 16:36 [Bug c++/40177] New: ADL with non-unqualified-id schaub-johannes at web dot de
@ 2009-11-05 22:11 ` jason at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-05 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jason at gcc dot gnu dot org  2009-11-05 22:11 -------
I agree: before we can do ADL we need to know that f is a template name, so we
need another declaration of f to be found by unqualified lookup, i.e. something
like

template <class T> void f(T,T);

It is correct to do ADL once we do that, though:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#561


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-05 22:11:24
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40177


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-05 22:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-17 16:36 [Bug c++/40177] New: ADL with non-unqualified-id schaub-johannes at web dot de
2009-11-05 22:11 ` [Bug c++/40177] " jason at gcc dot gnu dot org

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).