Repository navigation
Use template parameter objects for class-type NTTPs in signatures [GH #414] #422
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
+202
−115
Merged
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
21 changes: 21 additions & 0 deletions
21
src/pending_changes/gh-414-class-type-template-param-object.chng.txt
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,21 @@ | ||
| [GH #414] | ||
| Class-type template parameter objects in function template signatures | ||
|
|
||
| A nontype template parameter of class type denotes a template parameter | ||
| object, which is a const lvalue. When such a parameter was used in the | ||
| signature of a function template, substituting template arguments treated | ||
| it as a prvalue instead. As a result, decltype applied to the | ||
| parenthesized parameter name produced the class type rather than a const | ||
| lvalue reference to it (causing a spurious "unexpected function type" | ||
| error), member accesses through the parameter had the wrong value category, | ||
| and taking the address of the parameter caused substitution to fail. That | ||
| is now fixed. For example, with --c++20: | ||
|
|
||
| struct A { }; | ||
| template <A V> void f(decltype((V)) v) { } | ||
| template <A V> auto g() -> decltype(&V); | ||
| void h() { | ||
| constexpr A a; | ||
| f<a>(a); // Previously an "unexpected function type" error. | ||
| g<a>(); // Previously, no instance of g matched. | ||
| } |
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
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 @@ | ||
| fe_only -DTEST_NUMBER=1 --c++20 Test_name.c |
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 @@ | ||
| fe_only -DTEST_NUMBER=2 --c++20 --g++ --gnu_version=150100 Test_name.c |
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 @@ | ||
| fe_only -DTEST_NUMBER=3 --c++20 --clang --clang_version=190000 Test_name.c |
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 @@ | ||
| fe_only -DTEST_NUMBER=4 --ms_c++20 --microsoft_version=1950 Test_name.c |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Script executed:
Repository: edgcpp/compiler
Length of output: 42104
Script executed:
Repository: edgcpp/compiler
Length of output: 41963
Script executed:
Repository: edgcpp/compiler
Length of output: 36462
Script executed:
Repository: edgcpp/compiler
Length of output: 42467
Preserve the object operand across a second rescan.
When partial substitution retains rescan information, a later deduction rescan can process the synthesized template-parameter object. Because
break_constant_source_corresp(cp)removes the initializer's symbol association,make_operand_for_rescanned_identifiertakes itsmake_constant_operandfallback instead of preserving the object lvalue. This can make&Vfail.Update
make_operand_for_rescanned_identifierto preserve the variable operand forvar->is_template_param_objectwhen the initializer has no constant symbol.Uh oh!
There was an error while loading. Please reload this page.
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 a pre-existing bug. I'm creating a separate issue for it. (Issue #423)
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.
@daveedvdv-nvidia Understood. Thanks for clarifying that this bug predates
#422. Handling it in a separate issue makes sense; I won’t press for a fix in this PR.You are interacting with an AI system.