-Wundefined-func-template warns that no definition is available for a pure virtual function (original) (raw)
The warning seems incorrect as B::bar is pure virtual and its definition isn't needed.
template class B { public: constexpr void foo(const T &) { bar(1); } virtual constexpr void bar(unsigned int) = 0; };
template class D : public B { public: constexpr void bar(unsigned int) override {} };
void test() { auto t = D(); t.foo(0); }
$ clang++ -std=c++20 test.cpp -Wundefined-func-template -c
test.cpp:4:35: warning: instantiation of function 'B<int>::bar' required here, but no definition is available [-Wundefined-func-template]
constexpr void foo(const T &) { bar(1); }
^
test.cpp:5:26: note: forward declaration of template entity is here
virtual constexpr void bar(unsigned int) = 0;
^
test.cpp:4:35: note: add an explicit instantiation declaration to suppress this warning if 'B<int>::bar' is explicitly instantiated in another translation unit
constexpr void foo(const T &) { bar(1); }
^
1 warning generated.