Issue |
128657
|
Summary |
False positive warning `warning: instantiation of variable 'declvar<A>' required here, but no definition is available`, when the definition is not required
|
Labels |
new issue
|
Assignees |
|
Reporter |
HolyBlackCat
|
Consider the following code:
```cpp
#include <utility>
struct A {explicit constexpr operator bool() const {return true;}};
struct B {int x = 1; explicit constexpr operator bool() const {return x;}};
template <typename T>
extern T declvar;
template <typename T>
concept C = requires{typename std::bool_constant<declvar<T> ? true : false>;};
static_assert(C<A>);
static_assert(!C<B>);
```
This works correctly on all 3 bug compilers including Clang (and seems to be the only good way of doing this).
But Clang emits a useless warning:
```none
<source>:10:50: warning: instantiation of variable 'declvar<A>' required here, but no definition is available [-Wundefined-var-template]
10 | concept C = requires{typename std::bool_constant<declvar<T> ? true : false>;};
| ^
<source>:7:10: note: forward declaration of template entity is here
7 | extern T declvar;
| ^
<source>:10:50: note: add an explicit instantiation declaration to suppress this warning if 'declvar<A>' is explicitly instantiated in another translation unit
10 | concept C = requires{typename std::bool_constant<declvar<T> ? true : false>;};
| ^
```
The variable definition isn't needed here, so it shouldn't warn.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs