Open
Description
Consider the following code: https://gcc.godbolt.org/z/acd5W9YMn
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 <auto T>
constexpr int dummy = 0;
template <typename T>
concept C = requires{dummy<declvar<T> ? true : false>;};
static_assert(C<A>);
static_assert(!C<B>);
This compiles 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:
<source>:11:28: warning: instantiation of variable 'declvar<A>' required here, but no definition is available [-Wundefined-var-template]
11 | concept C = requires{dummy<declvar<T> ? true : false>;};
| ^
<source>:5:10: note: forward declaration of template entity is here
5 | extern T declvar;
| ^
<source>:11:28: note: add an explicit instantiation declaration to suppress this warning if 'declvar<A>' is explicitly instantiated in another translation unit
11 | concept C = requires{dummy<declvar<T> ? true : false>;};
| ^
The variable definition isn't needed here, so it shouldn't warn.
Activity