[llvm-bugs] [Bug 46035] New: False-positive: -Wunused-variable warning triggers for non-instantiated class-template specialization
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 22 04:11:46 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46035
Bug ID: 46035
Summary: False-positive: -Wunused-variable warning triggers for
non-instantiated class-template specialization
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: jbakam at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Small repro via CRTP:
```
template <typename T, bool B>
struct Base {
void foo() {
// no-op
}
};
template <typename T>
struct Base<T, true> {
void foo() {
size_t var = 1; // <--- LoC for which the warning is issued for
}
};
template <bool B>
struct Derived : public Base<Derived<B>, B> {
void bar() {
this->foo();
}
};
Derived<false> d;
```
Compiling this code-excerpt with `clang++ -std=c++11 -Wall` results with
false-positive warning:
```
warning: unused variable 'var' [-Wunused-variable]
size_t var = 1;
```
I've checked other combos like {C++11, C++14, C++17, C++2a} x {clang-6,
clang-7, clang-8, ... clang-trunk} and warning is still there.
Mind that one does not have to `Derived<false> d;` to get a warning (it's in
the example for clarity reasons) and in real-world scenario `size_t var = ...`
is being used in the very next line (in production-code).
Thanks,
Adi
Mind
--
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/20200522/bae52f87/attachment-0001.html>
More information about the llvm-bugs
mailing list