[llvm-bugs] [Bug 25645] New: Error when a template-and-non-template-derived-class uses a nested type it inherits from its non-template-base-class
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 25 15:37:32 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25645
Bug ID: 25645
Summary: Error when a template-and-non-template-derived-class
uses a nested type it inherits from its
non-template-base-class
Product: clang
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: sugak at fb.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
```
% cat 1.cpp
class Base1 {
public:
typedef int base_int;
};
template <typename T>
class Base2 {};
template<typename T>
class A : public Base1, public Base2<T> {
public:
base_int f();
};
template<typename T>
typename A<T>::base_int A<T>::f() {
return 42;
}
int main() {
A<int> a;
return a.f();
}
% clang++ 1.cpp
1.cpp:16:31: error: return type of out-of-line definition of 'A::f' differs
from that in the declaration
typename A<T>::base_int A<T>::f() {
~~~~~~~~~~~~~~~~~~~~~~~ ^
1.cpp:12:12: note: previous declaration is here
base_int f();
~~~~~~~~ ^
1 error generated.
% clang++ --version
clang version 3.8.0 (trunk 251726)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```
Here `base_int` in A<T> comes from `Base1`, which is not a template, and
according to look up rules compiler should look in this nondependent base class
for base_int. When A<T> inherits only Base1, there is no error.
Works with gcc 4.9.2
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151125/b8dbd29e/attachment-0001.html>
More information about the llvm-bugs
mailing list