https://bugs.llvm.org/show_bug.cgi?id=50533
Bug ID: 50533
Summary: Wunused-const-variable warns when variable template is
used in body of uninstantiated function template
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
The following translation unit
```
namespace {
template<typename T>
constexpr bool false_ = false;
}
template<typename T>
void f() {
static_assert(false_<T>);
}
```
warns when compiled with `-Wunused-const-variable`:
```
<source>:4:16: warning: unused variable 'false_' [-Wunused-const-variable]
constexpr bool false_ = false;
^
1 warning generated.
Compiler returned: 0
```
even though the variable is clearly used.
See it live: https://godbolt.org/z/oYxMq1K6r
If an instantiation of `f` is visible, the warning goes away, but not all
instantiations are necessarily visible. The warning is also triggered with the
following slightly larger translation unit:
```
namespace {
template<typename T>
constexpr bool false_ = false;
}
template<typename T>
void f() {
static_assert(false_<T>);
}
template<typename T>
concept c = requires { f<T>(); };
static_assert(c<int>);
```
See it live: https://godbolt.org/z/f74G5Tx54
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs