Bug 11296 - Unqualified lookup should only use the definition context, if the funciton call is dependent (§14.6.4.2, p1, bullet 1)
Summary: Unqualified lookup should only use the definition context, if the funciton ca...
Status: RESOLVED DUPLICATE of bug 2922
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-06-23 17:59 UTC by Martin Sebor
Modified: 2004-08-11 08:31 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-05-25 01:58:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2003-06-23 17:59:07 UTC
The program below is expected to exit with a status of 0. Only symbols from the
definition context are to be considered during unqualified lookup (bullet 1),
and only symbols defined in associated namespaces in both the definition and
instantiation context are to be considered during Koenig lookup (bullet 2). When
compiled with gcc 3.2, the program returns 1 instead, indicating that gcc fails
to correctly implement 14.6.4.2, p1, bullet 1 in that it considers symbols
outside the definition context of N::bar during unqualified lookup. EDG eccp -A
(i.e., strict mode) implements the rules correctly. For a discussion of the
rules see the email thread at c++std-core@research.att.com starting with
c++std-core-10009.

$ cat t.cpp; g++ -static t.cpp && ./a.out ; echo $?
namespace N {
template <class T> T foo (T) { return T (); }
template <class T> T bar (T t) { return foo (t); }
}

struct S { S (int i = 0): i_ (i) { } int i_; };

namespace N {
/* template <> */ S foo (S) { return S (1); }
}

int main ()
{
     return 1 == N::bar (S ()).i_;
} 
1
Comment 1 Giovanni Bajo 2003-06-24 02:14:28 UTC
Confirmed. In other words, GCC incorrectly picks the second N::foo() because it 
lookups all the functions available at the point of call, while it should only 
use the definition context to lookup the function names for unqualified lookup. 
This would make it call the first N::foo().
Comment 2 Andrew Pinski 2004-07-29 05:16:31 UTC
This is another dup of bug 2922.

*** This bug has been marked as a duplicate of 2922 ***