[llvm-bugs] [Bug 24806] New: Fail to report error when base class member shadows template parameter
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Sep 13 19:47:24 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: writalnaie at gmail.com
CC: llvm-bugs at lists.llvm.org
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150914/632ededc/attachment-0001.html>
More information about the llvm-bugs
mailing list