https://llvm.org/bugs/show_bug.cgi?id=24806
Bug ID: 24806
Summary: Fail to report error when base class member shadows
template parameter
Product: clang
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Clang does not report error when parent class member shadows derived template
class's template parameter. For example, the following code does not report any
error.
===== begin of test.cpp =====
#include <stdio.h>
struct Base {
int data;
Base() : data(20) {}
};
template<int data>
struct Derived : public Base {
void func() {
printf("%s %d\n", __PRETTY_FUNCTION__, data);
}
};
int main() {
Derived<30>().func();
return 0;
}
===== end of test.cpp =====
===== begin of output =====
$ ../clang-3.7 test.cpp -Wall
$ ./a.out
void Derived<30>::func() [data = 30] 20
===== end of output ======
However, when the declaration of `int data` is moved to the body of Derived,
clang report the error of shadowing template parameter. Without report, it is
hard to diagnose the misbehavior of the program with the shadowing code.
By the way, it seems other compiler such as gcc also fail to report the error.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs