-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang incorrectly emits -Wundefined-func-template
warning
#92486
Comments
@llvm/issue-subscribers-clang-frontend Author: Akira Hatanaka (ahatanak)
$ cat test.cpp
```
class c {
protected:
virtual ~c();
virtual int *d() const;
};
template <typename> class e : c { int t = sizeof(e<int>);
|
It looks like clang started emitting the warning after 99500e8. clang doesn't warn if I revert the commit. |
CC @Fznamznon |
This also happens in Clang 18 if we have https://godbolt.org/z/7GzabWKxq class c {
protected:
virtual ~c();
virtual int d() const;
};
template <typename> class e : c {
constexpr ~e() = default;
int d() const override;
};
int t = sizeof(e<int>); This appears to have just been exposed when the implicitly-declared destructor became |
I think this is ill-formed NDR -- the class is required to be complete, so its virtual functions are ODR-used. In practice, |
$ cat test.cpp
$ clang++ -c -std=gnu++2b -Wundefined-func-template test.cpp
test.cpp:7:27: warning: instantiation of function 'e::d' required here, but no definition is available [-Wundefined-func-template]
7 | template class e : c {
I don’t think instantiation of e::d is needed to compute the size of the class.
The text was updated successfully, but these errors were encountered: