-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[Clang] Fix a partial ordering bug involving CTAD injected template arguments #149782
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
Merged
+34
−3
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not immediately clear to me these injected class template types only appear at the top level type of the parameters, that they can't appear nested within, and there is no explanation for that.
If we can't fix this at the deduction guide level, I think the next best thing would be to make sure the substitution here produces the right injected vs non-injected type to match the other side, by manipulating the current context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you that fixing the deduction guide generation looks more optimal than current way, but that seemed to going to mess up more things, see the comment in
transformFunctionProtoType
:So staying with injected types looks like the only option to me. (For now, we just want to restore the 19's behavior)
The bug happens when the generated CTAD guide (which is generated from a copy constructor) comes along with another deduction guide that is generated from a user-defined constructor; since the first guide uses the injected class types, the default substitution would fail, hence the failure of type comparision in consistency checking, resulting in wrong partial ordering.
Besides CTAD guides, we don't appear to suffer from the issue because we don't model user-written function parameters with InjectedClassNameType - which is also what the above comment reflects.
So to me, they can't be nested - we promised it when forming the the deduction guide.
I tried to fix it at the substitution level, but unfortunately it didn't work very well. Some regressions surfaced, and all of them are due to the inconsistencies between the types in A, DeducedArgs. That's why I tweaked types at here in the end.
I'm happy to add some comments, as long as the approach makes sense to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, if we want a quick solution which can be back ported, that will do.
Can we enable this workaround only on the side which is the implicit deduction guide?
This would make this self-documented as a workaround, with a clear link to implicit deduction guides, and it would limit it to applying to known situations.
A comment calling this out as a workaround is also in order.