[LLVMbugs] [Bug 7408] New: Class instantiated as covariant return type of method in 'D' cannot see members declared later in 'D'
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jun 18 09:41:17 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7408
Summary: Class instantiated as covariant return type of method
in 'D' cannot see members declared later in 'D'
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jyasskin at google.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
The interesting features seem to be that
1. We have a covariant return
2. The returned subclass refers to a typedef in the class that returned it.
3. That typedef is declared after the method returning covariantly.
Comeau has exactly the same problem.
-----------
Test case:
$ cat test.cc
struct BaseReturn {
};
template <typename T> struct Base{
virtual BaseReturn* GetEdges(long n) { return 0;}
};
template <typename T> struct Derived;
template<typename T>
struct Covariant : BaseReturn {
typename Derived<T>::LaterTypedef x;
};
template <typename T>
struct Derived : Base<T> {
virtual Covariant<T>* GetEdges(long n) {
return 0;
}
typedef char LaterTypedef;
};
Derived<long> derived;
$ gcc-4.5.0 -fsyntax-only test.cc && ./clang++ -fsyntax-only test.cc
test.cc:12:24: error: no type named 'LaterTypedef' in 'Derived<long>'
typename Derived<T>::LaterTypedef x;
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
test.cc:17:25: note: in instantiation of template class 'Covariant<long>'
requested here
virtual Covariant<T>* GetEdges(long n) {
^
test.cc:23:15: note: in instantiation of template class 'Derived<long>'
requested here
Derived<long> derived;
^
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