public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34870] New: template not instantiated for argument-dependent lookup
@ 2008-01-19 12:04 dragan at plusplus dot co dot yu
2008-01-19 12:08 ` [Bug c++/34870] " dragan at plusplus dot co dot yu
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: dragan at plusplus dot co dot yu @ 2008-01-19 12:04 UTC (permalink / raw)
To: gcc-bugs
This code should be legal:
template <typename T>
struct Foo
{
template <typename Z>
friend void func(const Foo &) {}
};
void check(const Foo<int> & x)
{
// Foo<int> weird; // uncomment this line and all works
func<int>(x); // <-- GCC issues an ERROR
}
After a brief discussion on gcc@gcc.gnu.org, it has been concluded that this
sample code should work. Apparently, 'func' should have been found by
argument-dependent lookup, instantiating 'Foo<int>' in the process.
Here are links to backup these claims, as specified in the discussion by people
involved:
- C++ Standard
- 3.4.2 [basic.lookup.koenig]
- 14.6.5 [temp.inject]
- 7.3.1.2 [namespace.memdef] p3
- Vandevoorde and Josuttis' C++ Templates, section 9.2.2
- http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#34
(gcc@gcc.gnu.org thread 'A simple sample code involving templates, friends and
lookup')
--
Summary: template not instantiated for argument-dependent lookup
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dragan at plusplus dot co dot yu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] template not instantiated for argument-dependent lookup
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
@ 2008-01-19 12:08 ` dragan at plusplus dot co dot yu
2008-01-21 10:37 ` rguenth at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: dragan at plusplus dot co dot yu @ 2008-01-19 12:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dragan at plusplus dot co dot yu 2008-01-19 11:39 -------
Created an attachment (id=14974)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14974&action=view)
a simple test case (the same as in the bug description)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] template not instantiated for argument-dependent lookup
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
2008-01-19 12:08 ` [Bug c++/34870] " dragan at plusplus dot co dot yu
@ 2008-01-21 10:37 ` rguenth at gcc dot gnu dot org
2008-12-30 5:47 ` pinskia at gcc dot gnu dot org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-21 10:37 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2008-01-21 10:04:52
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] template not instantiated for argument-dependent lookup
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
2008-01-19 12:08 ` [Bug c++/34870] " dragan at plusplus dot co dot yu
2008-01-21 10:37 ` rguenth at gcc dot gnu dot org
@ 2008-12-30 5:47 ` pinskia at gcc dot gnu dot org
2008-12-30 11:46 ` rguenth at gcc dot gnu dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-30 5:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2008-12-30 05:45 -------
*** Bug 34827 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] template not instantiated for argument-dependent lookup
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (2 preceding siblings ...)
2008-12-30 5:47 ` pinskia at gcc dot gnu dot org
@ 2008-12-30 11:46 ` rguenth at gcc dot gnu dot org
2008-12-30 11:47 ` rguenth at gcc dot gnu dot org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-30 11:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2008-12-30 11:44 -------
*** Bug 34827 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] template not instantiated for argument-dependent lookup
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (3 preceding siblings ...)
2008-12-30 11:46 ` rguenth at gcc dot gnu dot org
@ 2008-12-30 11:47 ` rguenth at gcc dot gnu dot org
2008-12-30 13:22 ` [Bug c++/34870] argument-dependent lookup wronly finds friend declaration dragan at plusplus dot co dot yu
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-30 11:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-12-30 11:44 -------
IMHO the friend declaration isn't a declaration for func.
At least it shouldn't inject the name into Foo<T>.
EDG agrees with me here:
icpc -S t.C -strict_ansi
t.C(12): error: identifier "func" is undefined
func<int>(x);
^
t.C(12): error: type name is not allowed
func<int>(x);
^
compilation aborted for t.C (code 2)
with and without the "weird" decl. Which is IMHO correct.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|rejects-valid |accepts-invalid
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup wronly finds friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (4 preceding siblings ...)
2008-12-30 11:47 ` rguenth at gcc dot gnu dot org
@ 2008-12-30 13:22 ` dragan at plusplus dot co dot yu
2009-01-15 23:12 ` jason at gcc dot gnu dot org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: dragan at plusplus dot co dot yu @ 2008-12-30 13:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from dragan at plusplus dot co dot yu 2008-12-30 13:20 -------
The standard says that the friend declaration should inject the name 'func'
into the enclosing namespace, but in a way that it can be found only by ADL.
Here is a test case without templates:
struct Foo
{
friend void func(const Foo &) {}
};
void check(const Foo & x)
{
func(x); <-- ADL, no error
::func(x); <-- not ADL, GCC issue an error
}
GCC handles this case correctly. The problem is it doesn't work
when templates come to play.
I personally find this behavior of great value. It reduces name clobbering.
I can for example do:
struct Foo {
template <typename Type>
friend bool is(const Foo & foo);
};
... and not clobber any namespace with a function of such non-unique name 'is'.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup wronly finds friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (5 preceding siblings ...)
2008-12-30 13:22 ` [Bug c++/34870] argument-dependent lookup wronly finds friend declaration dragan at plusplus dot co dot yu
@ 2009-01-15 23:12 ` jason at gcc dot gnu dot org
2009-01-16 4:54 ` [Bug c++/34870] argument-dependent lookup wrongly " jason at gcc dot gnu dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-15 23:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jason at gcc dot gnu dot org 2009-01-15 23:12 -------
3.4.2 begins "When an unqualified name is used as the postfix-expression in a
function call...." The call func<int>(x) does not get argument-dependent
lookup because func<int> is not an unqualified name, it's a template-id. The
testcase should be rejected with or without the declaration of weird.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup wrongly finds friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (6 preceding siblings ...)
2009-01-15 23:12 ` jason at gcc dot gnu dot org
@ 2009-01-16 4:54 ` jason at gcc dot gnu dot org
2009-01-16 21:22 ` dragan at plusplus dot co dot yu
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16 4:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jason at gcc dot gnu dot org 2009-01-16 04:54 -------
Actually, this is still an accepts-invalid bug when weird is uncommented.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
Summary|argument-dependent lookup |argument-dependent lookup
|wronly finds friend |wrongly finds friend
|declaration |declaration
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup wrongly finds friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (7 preceding siblings ...)
2009-01-16 4:54 ` [Bug c++/34870] argument-dependent lookup wrongly " jason at gcc dot gnu dot org
@ 2009-01-16 21:22 ` dragan at plusplus dot co dot yu
2009-03-27 18:34 ` jason at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: dragan at plusplus dot co dot yu @ 2009-01-16 21:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from dragan at plusplus dot co dot yu 2009-01-16 21:22 -------
Created an attachment (id=17123)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17123&action=view)
another test case
I disagree... here is another test case. Semantically, it is the same
as the first one, so there is no reason why "unqualified name" could
not include (among others) an unqualified template-id. Either it is
a defect in standard, or there is a place that says that template-id
can also be qualified or unqualified. This test case eliminates
the template-id, and we're back to my original bug report.
Hm... why do people try to close or invert this bug report?
It is fairly logical and with references to standard,
discussion and defect report...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup wrongly finds friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (8 preceding siblings ...)
2009-01-16 21:22 ` dragan at plusplus dot co dot yu
@ 2009-03-27 18:34 ` jason at gcc dot gnu dot org
2009-05-17 16:39 ` schaub-johannes at web dot de
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-27 18:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jason at gcc dot gnu dot org 2009-03-27 18:34 -------
You're right, a template-id does still get argument-dependent lookup.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup wrongly finds friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (9 preceding siblings ...)
2009-03-27 18:34 ` jason at gcc dot gnu dot org
@ 2009-05-17 16:39 ` schaub-johannes at web dot de
2009-11-05 22:08 ` [Bug c++/34870] argument-dependent lookup fails to find " jason at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: schaub-johannes at web dot de @ 2009-05-17 16:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from schaub-johannes at web dot de 2009-05-17 16:38 -------
A added another bug-report very similar to this that handles the case where the
friend definition is about a template:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40177 . GCC accepts in that case,
while it should reject.
--
schaub-johannes at web dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schaub-johannes at web dot
| |de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup fails to find friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (10 preceding siblings ...)
2009-05-17 16:39 ` schaub-johannes at web dot de
@ 2009-11-05 22:08 ` jason at gcc dot gnu dot org
2009-11-06 3:33 ` jason at gcc dot gnu dot org
2009-11-06 4:09 ` jason at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-05 22:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jason at gcc dot gnu dot org 2009-11-05 22:08 -------
The ADL and template-id issue:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#561
but I'm declaring this PR to be about the bug-002.cc testcase, which shows the
real bug here without the distraction of template-ids, which can be dealt with
in PR 40177.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|REOPENED |ASSIGNED
Keywords|accepts-invalid |rejects-valid
Last reconfirmed|2008-12-29 18:28:06 |2009-11-05 22:08:19
date| |
Summary|argument-dependent lookup |argument-dependent lookup
|wrongly finds friend |fails to find friend
|declaration |declaration
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup fails to find friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (11 preceding siblings ...)
2009-11-05 22:08 ` [Bug c++/34870] argument-dependent lookup fails to find " jason at gcc dot gnu dot org
@ 2009-11-06 3:33 ` jason at gcc dot gnu dot org
2009-11-06 4:09 ` jason at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-06 3:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jason at gcc dot gnu dot org 2009-11-06 03:33 -------
Subject: Bug 34870
Author: jason
Date: Fri Nov 6 03:33:06 2009
New Revision: 153958
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153958
Log:
PR c++/34870
* name-lookup.c (arg_assoc_class): Call complete_type.
* pt.c (instantiate_class_template): Call uses_template_parms
instead of dependent_type_p.
Added:
trunk/gcc/testsuite/g++.dg/lookup/koenig7.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/name-lookup.c
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/34870] argument-dependent lookup fails to find friend declaration
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
` (12 preceding siblings ...)
2009-11-06 3:33 ` jason at gcc dot gnu dot org
@ 2009-11-06 4:09 ` jason at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-06 4:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jason at gcc dot gnu dot org 2009-11-06 04:08 -------
Fixed for 4.5.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-11-06 4:09 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-19 12:04 [Bug c++/34870] New: template not instantiated for argument-dependent lookup dragan at plusplus dot co dot yu
2008-01-19 12:08 ` [Bug c++/34870] " dragan at plusplus dot co dot yu
2008-01-21 10:37 ` rguenth at gcc dot gnu dot org
2008-12-30 5:47 ` pinskia at gcc dot gnu dot org
2008-12-30 11:46 ` rguenth at gcc dot gnu dot org
2008-12-30 11:47 ` rguenth at gcc dot gnu dot org
2008-12-30 13:22 ` [Bug c++/34870] argument-dependent lookup wronly finds friend declaration dragan at plusplus dot co dot yu
2009-01-15 23:12 ` jason at gcc dot gnu dot org
2009-01-16 4:54 ` [Bug c++/34870] argument-dependent lookup wrongly " jason at gcc dot gnu dot org
2009-01-16 21:22 ` dragan at plusplus dot co dot yu
2009-03-27 18:34 ` jason at gcc dot gnu dot org
2009-05-17 16:39 ` schaub-johannes at web dot de
2009-11-05 22:08 ` [Bug c++/34870] argument-dependent lookup fails to find " jason at gcc dot gnu dot org
2009-11-06 3:33 ` jason at gcc dot gnu dot org
2009-11-06 4:09 ` 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).