Bug 25495 - 4.1 regression, code rejected: can't find matching function
Summary: 4.1 regression, code rejected: can't find matching function
Status: RESOLVED DUPLICATE of bug 2922
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-19 15:53 UTC by Benoit Foucher
Modified: 2005-12-19 16:44 UTC (History)
7 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
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 Benoit Foucher 2005-12-19 15:53:45 UTC
Ice for C++ 3.0 from ZeroC (http://www.zeroc.com/download.html, source code available) doesn't compile anymore with GCC from the 4.1 branch. It compiled fine with 4.0.1 and 4.0.2. I managed to reproduce the problem with the following sample code:

----
class Dummy1;
class Dummy2;
void incRef(Dummy1*);
void incRef(Dummy2*);

template<typename T>
class Handle
{
public:
    Handle(T* r = 0) { incRef(r); }
};

namespace Test
{
class Process;
typedef ::Handle<Process> ProcessPrx;
}
void incRef(::Test::Process*);

void 
m()
{
    ::Test::ProcessPrx process;
}
----

I'm getting the following error:

---
Main.cpp: In constructor 'Handle<T>::Handle(T*) [with T = Test::Process]':
Main.cpp:24:   instantiated from here
Main.cpp:11: error: no matching function for call to 'incRef(Test::Process*&)'
Main.cpp:4: note: candidates are: void incRef(Dummy1*)
Main.cpp:5: note:                 void incRef(Dummy2*)
---

If the definition of the 'Handle' template is moved at the top, it compiles fine.  The output of 'gcc -v -save-temps Main.cpp':

---
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-shared --enable-languages=c,c++ --prefix=/opt/gcc-4.1 --enable-threads=posix
Thread model: posix
gcc version 4.1.0 20051219 (prerelease)
 /opt/gcc-4.1/libexec/gcc/i686-pc-linux-gnu/4.1.0/cc1plus -E -quiet -v -D_GNU_SOURCE Main.cpp -mtune=pentiumpro -fpch-preprocess -o Main.ii
ignoring nonexistent directory "/opt/gcc-4.1/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gcc-4.1/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../../include/c++/4.1.0
 /opt/gcc-4.1/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../../include/c++/4.1.0/i686-pc-linux-gnu
 /opt/gcc-4.1/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../../include/c++/4.1.0/backward
 /usr/local/include
 /opt/gcc-4.1/include
 /opt/gcc-4.1/lib/gcc/i686-pc-linux-gnu/4.1.0/include
 /usr/include
End of search list.
 /opt/gcc-4.1/libexec/gcc/i686-pc-linux-gnu/4.1.0/cc1plus -fpreprocessed Main.ii -quiet -dumpbase Main.cpp -mtune=pentiumpro -auxbase Main -version -o Main.s
GNU C++ version 4.1.0 20051219 (prerelease) (i686-pc-linux-gnu)
        compiled by GNU C version 4.1.0 20051219 (prerelease).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64389
Compiler executable checksum: 6367aa9360ae7c92e39b7212b696b4ab
Main.cpp: In constructor 'Handle<T>::Handle(T*) [with T = Test::Process]':
Main.cpp:25:   instantiated from here
Main.cpp:11: error: no matching function for call to 'incRef(Test::Process*&)'
Main.cpp:4: note: candidates are: void incRef(Dummy1*)
Main.cpp:5: note:                 void incRef(Dummy2*)
Comment 1 Andrew Pinski 2005-12-19 16:44:25 UTC
This is invalid C++ which was fixed to be rejected in 4.1.0.

This is a dup of bug 2922 which was fixed in 4.1.0.

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