Skip to content

CWG2738 [expr.prim.id.unqual] What id-expression denotes a destructor is underspecified #313

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

Open
xmh0511 opened this issue May 8, 2023 · 4 comments

Comments

@xmh0511
Copy link

xmh0511 commented May 8, 2023

Full name of submitter (unless configured in github; will be published with the issue): Jim X

The original issue is cplusplus/draft#5449, which is confirmed by @opensdh in cplusplus/draft#5346 (comment), it should be a CWG issue.

@jensmaurer
Copy link
Member

CWG2738

@jensmaurer jensmaurer changed the title [expr.prim.id.unqual] What id-expression denotes a destructor is underspecified CWG2738 [expr.prim.id.unqual] What id-expression denotes a destructor is underspecified May 27, 2023
@xmh0511
Copy link
Author

xmh0511 commented Sep 20, 2023

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].

@jensmaurer
Copy link
Member

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)?

@opensdh
Copy link

opensdh commented Sep 20, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants