-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
CTAD: implement DR2628 implicit deduction guides should propagate constraints #98592
Comments
@llvm/issue-subscribers-clang-frontend Author: Haojian Wu (hokein)
https://cplusplus.github.io/CWG/issues/2628.html
|
Can you provide and example that would demonstrate the difference? I am looking at the example from the DR: https://godbolt.org/z/WEaqzd9he and it is not obvious what behavior I should see and how I would determine it is correct. |
If we look at it from a different angle (the AST point of view), it becomes more obvious https://godbolt.org/z/zed6846re:
The implicit deduction guide is:
The associated constraints is |
I think the behavior of clang is already conforming now because in
Regarding the AST part, it's probably unnecessary for the synthesized declaration to always have a conjunction form. We have checked the constraints of Perhaps the nuance the user might note is the implicit guide printed in diagnostics. However, the issue would not be so much outstanding in that regard. |
Thanks for taking a look on this. I think the form of the attached constraint directly affects the final result of template argument deduction. Consider the following example:
If I understand the standard correctly, the implicit deduction guide should be chosen because it is more constrained than the explicitly written deduction guide, according to over.match.best.general. However, it seems that all compilers fail on this case, https://godbolt.org/z/PKhK1WvTo. The following example works as expected, https://godbolt.org/z/cMEjvrb4n
However, when the constraint is moved after the constructor declaration, it doesn’t work in Clang (looks like a different bug in clang), https://godbolt.org/z/xKM6MPobT
|
Thanks for the clarification. I tested locally, and indeed if we combine these constraints together, then the first example compiles. I suspect the third one is not working because we only preserved constraints from the template parameters, but we didn't do that for the function declarations in the process of transforming the constructor. |
…ld propagate constraints" (#111143) Closes llvm/llvm-project#98592
https://cplusplus.github.io/CWG/issues/2628.html
The text was updated successfully, but these errors were encountered: