-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang] visit constraint of NTTP #91842
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
Closed
Closed
Changes from all commits
Commits
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s | ||
// expected-no-diagnostics | ||
|
||
template<typename T, typename U> | ||
constexpr bool is_same_v = false; | ||
|
||
template<typename T> | ||
constexpr bool is_same_v<T, T> = true; | ||
|
||
template<typename T, typename U> | ||
concept same_as = is_same_v<T, U>; | ||
|
||
template <auto> | ||
struct A {}; | ||
|
||
template <same_as<int> auto p> | ||
struct A<p> {}; | ||
|
||
A<0> a; |
Oops, something went wrong.
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.
This is suspicious... I don't see any FIXMEs around suggesting this was not in conformance with the standards.
@erichkeane @cor3ntin any thoughts?
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.
The only difference is
D auto
vsE auto
E
subsumesD
so the second partial specialization is more constrained and we should pick that.So I believe the existing test is correct and we would be introducing a regression.
It is interesting to consider that GCC, EGG and MSVC all reject that code so it is possible
I am missing something
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.
https://compiler-explorer.com/z/c87771xKf
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.
[temp.over.link]p6.3
Oops, I forgot I posted the standard wording on that issue, and therefore this seems reasonable..?
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 think the quote can explain why we should report error here. Maybe more work is required to find out where we do the ignore and how this patch impacts this case.
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.
When instantiation, we are checking which one of the two partial specialization is more specialized. Obviously, the first one(
auto D
) is not more specialized than the second(auto E
). When applied this patch, the second one is not more specialized than the first as well. This is becauseisSameTemplateArg
returnfalse
and the result is notTemplateDeductionResult::Success
.Although we get correct result, it is not because of ignoring the type-constraint. Back to the quote, if we ignore the use of type-constraints for placeholder types, is the following example ill-formed due to their equivalent template arguments?
But EDG, gcc and MSVC all accept this code. So I think the existing test is rejected may not be related to the quote. WDYT? @cor3ntin @zyn0217 @erichkeane