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: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs