Issue 74016
Summary `-Wundefined-func-template` warns that no definition is available for a pure virtual function
Labels clang:frontend, false-positive
Assignees
Reporter ahatanak
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to