Consider this simple code.
struct Foo {
template <typename T>
struct Bar {
~Bar();
};
};
with the out-of-line implementation
template <typename T>
Foo::Bar<T>::~Bar()
{
// dtor implementation
}
Using clang (up to current trunk), with -std=c++20 and -Wdtor-name issues a warning: warning: ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~' [-Wdtor-name], and requires the implementation be changed to this.
template <typename T>
Foo::Bar<T>::~Bar<T>()
{
// dtor implementation
}
But, CWG 2237 makes this invalid (at least in a plain class template). Maybe it wasn't intended to extend to a nested class template, or maybe clang has a bug?
FWIW, gcc (current trunk) accepts the first one, and issues a compile warning for the second: warning: template-id not allowed for destructor in C++20 [-Wtemplate-id-cdtor]
Note that when using -Werror (which I do), these warnings are errors.
I assume this is a clang bug, but before I filed one, I wanted to make sure my understanding wasn't way off base.
template<typename T> Foo::Bar<T>::Bar::~Bar(), not~Bar<T>(): godbolt.org/z/68nvhhzEeFoo::Bar<T>::Bar::Bar::Bar::Bar::~Bar(). Which is kind of like having a file path/Users/jodyh/proj/././././Foo.cpp.