-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Only first destructor is considered when constraints are used #45614
Comments
[class.dtor]p4: "At the end of the definition of a class, overload resolution is performed among the prospective destructors declared in that class with an empty argument list to select the destructor for the class, also known as the selected destructor. The program is ill-formed if overload resolution fails." So I guess that should be accepted. On a related note, both clang and gcc accept the following, which seems wrong: template <bool B> struct A {
~A() requires (B) { }
};
int x = sizeof(A<false>); |
I don't believe we implement any of http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0848r3.html (which added the eligible special member & prospective destructor rules) yet. |
N.B. P2493R0 proposes an update to |
Is there anyone working on this. It also affects other features such as |
@llvm/issue-subscribers-clang-frontend |
This patch implements a necessary part of P0848, the overload resolution for destructors. It is now possible to overload destructors based on constraints, and the eligible destructor will be selected at the end of the class. The approach this patch takes is to perform the overload resolution in Sema::ActOnFields and to mark the selected destructor using a new property in FunctionDeclBitfields. CXXRecordDecl::getDestructor is then modified to use this property to return the correct destructor. This closes llvm#45614. Reviewed By: #clang-language-wg, erichkeane Differential Revision: https://reviews.llvm.org/D126194
Extended Description
When there are multiple destructors constrained with a requires clause, only the first one is considered, like in the following code:
The compiler reports the following error:
The compiler prematurely reports an error about an invalid reference to the destructor because the constraint on the first variant was not satisfied, without checking the second variant.
The same code compiles with GCC without any problems.
The text was updated successfully, but these errors were encountered: