Open xmh0511 opened 1 year ago
CWG2738
The proposal wording may have an issue here
A type-name or decltype-specifier prefixed by ~ denotes the destructor of the named type; see 7.5.4.4 [expr.prim.id.dtor].
What if the type-name is a template name?
template<class T>
struct A{};
int main(){
auto ptr = new A<int>;
ptr->~A();
}
In this case the type-name A
is not a type, instead, it is a template name. It may need to be changed to
A type-name or decltype-specifier prefixed by ~ denotes the destructor of the named type or the named template; see 7.5.4.4 [expr.prim.id.dtor].
A template doesn't have a destructor, only class types do.
Also, don't you get member name lookup for this case, finding the injected-class-name "A" (which is a type name, not a template name)?
A template doesn't have a destructor, only class types do.
CTAD enters the chat
One could easily imagine extending its logic to destructors, but fortunately the ordinary interpretation is what we want here.
Full name of submitter (unless configured in github; will be published with the issue): Jim X
The original issue is https://github.com/cplusplus/draft/issues/5449, which is confirmed by @opensdh in https://github.com/cplusplus/draft/issues/5346#issuecomment-1072949401, it should be a CWG issue.