[LLVMbugs] [Bug 10730] New: Wrong hiding of virtual function
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Aug 24 07:00:29 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10730
Summary: Wrong hiding of virtual function
Product: new-bugs
Version: unspecified
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: clang2007-inheritance at yahoo.de
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=7116)
--> (http://llvm.org/bugs/attachment.cgi?id=7116)
The code file (main.cpp)
If I compile the added file using:
clang -c -Wall -pedantic main.cpp
I receive the following warnings and errors:
main.cpp:17:19: warning: 'CObject::Get' hides overloaded virtual function
[-Woverloaded-virtual]
virtual CObject* Get(long nIndex)
^
main.cpp:7:21: note: hidden overloaded virtual function 'CRoot::Get' declared
here
virtual const long Get()
^
main.cpp:28:21: error: too few arguments to function call, expected 1, have 0
std::cout << o.Get() << std::endl;
~~~~~ ^
Warning and Error are both wrong. If you duplicate the method in question from
CRoot to CObject the error disappears.
The code from the file:
#include <iostream>
class CRoot
{
public:
virtual const long Get()
{
return 1;
}
};
class CObject : public CRoot
{
public:
virtual CObject* Get(long nIndex)
{
return this;
}
};
CObject o;
int main()
{
std::cout << o.Get() << std::endl;
return 0;
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list