Bug 24948 - lookup chooses the wrong overload
Summary: lookup chooses the wrong overload
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 2922
Blocks:
  Show dependency treegraph
 
Reported: 2005-11-20 02:57 UTC by Martin Sebor
Modified: 2005-11-20 03:04 UTC (History)
1 user (show)

See Also:
Host: all
Target: all
Build: all
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2005-11-20 02:57:43 UTC
I believe gcc is in error for calling the int* overload in the program below.
Sorry if this is a duplicate -- I went through the many lookup bugs in Bugzilla but none of them looked quite like this one.

$ cat t.cpp && g++ -pedantic -W t.cpp && ./a.out
#include <assert.h>

int foo (void*) { return 0; }
template <class T> int bar (T *p) { return foo (p); }
int foo (int*) { return 1; }

int main ()
{
   assert (0 == bar ((int*)0));
}
Assertion failed: 0 == bar ((int*)0), file t.cpp, line 9
Abort (core dumped)
Comment 1 Andrew Pinski 2005-11-20 03:04:10 UTC
This was fixed by the same patch which fixed PR 2922.  The issue was that GCC was not keeping track of the overloaded set.