[LLVMbugs] [Bug 13152] New: Nested classes member functions collide with inner class member functions
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jun 19 14:41:17 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13152
Bug #: 13152
Summary: Nested classes member functions collide with inner
class member functions
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: hallnicks at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Suppose you have a nested class like so:
// Begin clang.cpp
#include <cstdio>
template<class T>
class TemplatedClass
{
public:
class NestedBaseClass
{
public:
NestedBaseClass() { }
~NestedBaseClass(){ }
protected:
void doImportantWork()
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
}
};
class Subclass : public NestedBaseClass
{
public:
Subclass( ) { }
~Subclass( ) { }
void DoWork()
{
doImportantWork();
}
};
void doImportantWork(int i, double d);
};
template <class T>
void TemplatedClass<T>::doImportantWork(int i , double d) {
fprintf(stderr, "i=%i, d=%lf\n", i, d);
}
int main( void )
{
TemplatedClass<int>().doImportantWork(1, 1.0f);
return 0;
}
// end clang.cpp
Compiling this with GCC does not produce an error and the expected method is
invoked.
$ g++ clang.cpp -o test && ./test
i=1, d=1.000000
Clang finds a problem with this. I agree that there is an issue with this
choice of naming but do not believe it should result in an error. It also
appears to be a bit of an edge case.
clang.cpp:28:6: error: call to non-static member function 'doImportantWork' of
'TemplatedClass' from nested type 'Subclass'
doImportantWork();
^~~~~~~~~~~~~~~
1 error generated.
--
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