-
Notifications
You must be signed in to change notification settings - Fork 15k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should notgood first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute
Description
The warning seems incorrect as B::bar
is pure virtual and its definition isn't needed.
$ cat test.cpp
template <typename T> class B {
public:
constexpr void foo(const T &) { bar(1); }
virtual constexpr void bar(unsigned int) = 0;
};
template <typename T> class D : public B<T> {
public:
constexpr void bar(unsigned int) override {}
};
void test() {
auto t = D<int>();
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.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should notgood first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute