Bug 78641

Summary: code completion: overloaded members in derived classes not hidden when redefined
Product: [Applications] kdevelop Reporter: Daniel Franke <franke.daniel>
Component: Code completionAssignee: KDevelop Developers <kdevelop-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 3.0.2   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Daniel Franke 2004-03-28 21:46:00 UTC
Version:           3.0.2 (using KDE 3.2.1, compiled sources)
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-99-default

Daniel:

Assume two simple classes (stripped down example):
--
class A {
public:
      void print(const string& t) { print(t.c_str()); }
      virtual void print(const char *s) { cout << "A: " << s; }
};

class B : public A {
public:
      void print(const char *s) { cout << "B: " << s; }
};
--

and a short code snipplet:

--
string hello = "Hello";
A *a = new B;
a->[ctrl+space]
--
Here code completion offers both print-methods, therefore:
--
string hello = "Hello";
A *a = new B;
a->print(hello)
--
As expected, gcc compiles the code, "Hello" is printed at stdout.

A small change:
--
string hello = "Hello";
B *b = new B;
b->[ctrl+space]
--
Again, code completion offers both print methods.
--
string hello = "Hello";
B *b = new B;
b->print(hello);
--
gcc complains:
--
home/daniel/cvs/test/src/test.cpp: In function `int main(int, char**)':
/home/daniel/cvs/test/src/test.cpp:51: error: no matching function for
call to `B::print(std::string)'
/home/daniel/cvs/test/src/test.cpp:42: error: candidates are: virtual void
B::print(const char*)

----
Jens Dagerbo wrote (kdevelop-devel):

Quoting Eckel:
"If a base class has a function name that's overloaded several times, 
redefining that function name in the derived class will hide _all_ the 
base-class versions."

I don't think this is the worst bug in the CC mechanism, but it is incorrect 
and should probably be reported. ;)
Comment 1 Daniel Franke 2005-01-14 14:26:33 UTC
Still valid in kdevelop-3.1.91, KDE-3.3.91 (beta1), CVS 050113
Comment 2 Amilcar do Carmo Lucas 2005-01-14 14:33:51 UTC
Daniel seams to be a very good user. I trush him.
Comment 3 David Nolden 2007-01-19 20:02:12 UTC
Fixed in current svn