Repository navigation
Consider explicit conversions before aggregate fallback [GH #222] #222
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
Open
yronglin
wants to merge
1
commit into
edgcpp:main
Choose a base branch
from
yronglin:add_explicit_conv_before_agg_fallback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [GH #281] | ||
| Explicit conversion functions before parenthesized aggregate initialization | ||
|
|
||
| The front end could incorrectly attempt parenthesized aggregate initialization | ||
| instead of considering an explicit conversion function when directly | ||
| initializing an aggregate in C++20 mode. For example: | ||
|
|
||
| struct D { float x, y; }; | ||
| struct S { explicit operator D() const; }; | ||
| D d(S{}); // Previously an error in C++20 mode. Now okay. | ||
|
|
||
| That is now fixed. The rule allowing explicit conversion functions in this | ||
| context comes from Core issue 899 and applies in C++11 and later modes. The | ||
| failure occurred when C++20 parenthesized aggregate initialization was enabled. |
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 -tused --c++11 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 -tused --c++11 --gnu_version 160200 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 -tused --c++11 --clang_version 230100 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 -tused --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=5 -tused --c++20 --gnu_version 160200 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=6 -tused --c++20 --clang_version 230100 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=7 -tused --ms_c++20 --microsoft_version 1950 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,8 @@ | ||
| //type:fp | ||
|
yronglin marked this conversation as resolved.
Resolved
|
||
| //options:--c++11:--c++11 --gnu_version 160200:--c++11 --clang_version 230100:--c++20:--c++20 --gnu_version 160200:--c++20 --clang_version 230100:--ms_c++20 --microsoft_version 1950 | ||
| //options_all:-tused | ||
| //remark:Explicit conversion functions before aggregate fallback [GH #281] | ||
|
|
||
| struct D { float x, y; }; | ||
| struct S { explicit operator D() const; }; | ||
| D d(S{}); // Error, now okay. | ||
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 -tused --c++11 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 -tused --c++11 --gnu_version 160200 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 -tused --c++11 --clang_version 230100 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 -tused --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=5 -tused --c++20 --gnu_version 160200 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=6 -tused --c++20 --clang_version 230100 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=7 -tused --ms_c++20 --microsoft_version 1950 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,10 @@ | ||
| fe_only -DTEST_NUMBER=1 -tused --c++11 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,10 @@ | ||
| fe_only -DTEST_NUMBER=2 -tused --c++11 --gnu_version 160200 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,10 @@ | ||
| fe_only -DTEST_NUMBER=3 -tused --c++11 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,10 @@ | ||
| fe_only -DTEST_NUMBER=4 -tused --c++20 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,10 @@ | ||
| fe_only -DTEST_NUMBER=5 -tused --c++20 --gnu_version 160200 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,10 @@ | ||
| fe_only -DTEST_NUMBER=6 -tused --c++20 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,10 @@ | ||
| fe_only -DTEST_NUMBER=7 -tused --ms_c++20 --microsoft_version 1950 Test_name.c | ||
| "Test_name.c", line 13: error: no suitable conversion function from "A" to "int" exists | ||
| int i = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| "Test_name.c", line 14: error: no suitable user-defined conversion from "A" to "C" exists | ||
| C c = a; // Error: copy-initialization. | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,20 @@ | ||
| //type:fp | ||
| //options:--c++11:--c++11 --gnu_version 160200:--c++11 --clang_version 230100:--c++20:--c++20 --gnu_version 160200:--c++20 --clang_version 230100:--ms_c++20 --microsoft_version 1950 | ||
| //options_all:-tused | ||
| //remark:Core issue 899: Explicit conversion functions in direct class initialization | ||
|
|
||
| struct C { }; | ||
| struct A { | ||
| explicit operator int() const; | ||
| explicit operator C() const; | ||
| }; | ||
|
|
||
| struct B { | ||
| int i; | ||
| B(const A& a): i(a) { } // Okay. | ||
| }; | ||
|
|
||
| void f(A a) { | ||
| int j(a); // Okay: direct-initialization. | ||
| C c2(a); // Okay: direct-initialization (Core issue 899). | ||
| } |
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,15 @@ | ||
| //type:fn | ||
| //options:--c++11:--c++11 --gnu_version 160200:--c++11 --clang_version 230100:--c++20:--c++20 --gnu_version 160200:--c++20 --clang_version 230100:--ms_c++20 --microsoft_version 1950 | ||
| //options_all:-tused | ||
| //remark:Core issue 899: Explicit conversion functions in copy-initialization | ||
|
|
||
| struct C { }; | ||
| struct A { | ||
| explicit operator int() const; | ||
| explicit operator C() const; | ||
| }; | ||
|
|
||
| void f(A a) { | ||
| int i = a; // Error: copy-initialization. | ||
| C c = a; // Error: copy-initialization. | ||
| } |
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,24 @@ | ||
| fe_only -DTEST_NUMBER=1 -tused --c++11 Test_name.c | ||
| "Test_name.c", line 15: error: no instance of overloaded function "f" matches the argument list | ||
| argument types are: ({...}) | ||
| int i = f({A{}}); // Error: cannot copy-list-initialize the temporary int. | ||
| ^ | ||
| "Test_name.c", line 7: note: function "f(int *)" does not match because argument #1 does not match parameter | ||
| int f(int*); | ||
| ^ | ||
| "Test_name.c", line 6: note: function "f(int &&)" does not match because argument #1 does not match parameter | ||
| int f(int&&); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 16: error: no instance of overloaded function "g" matches the argument list | ||
| argument types are: ({...}) | ||
| int j = g({A{}}); // Likewise for a const lvalue reference. | ||
| ^ | ||
| "Test_name.c", line 9: note: function "g(int *)" does not match because argument #1 does not match parameter | ||
| int g(int*); | ||
| ^ | ||
| "Test_name.c", line 8: note: function "g(const int &)" does not match because argument #1 does not match parameter | ||
| int g(const int&); | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,24 @@ | ||
| fe_only -DTEST_NUMBER=2 -tused --c++11 --gnu_version 160200 Test_name.c | ||
| "Test_name.c", line 15: error: no instance of overloaded function "f" matches the argument list | ||
| argument types are: ({...}) | ||
| int i = f({A{}}); // Error: cannot copy-list-initialize the temporary int. | ||
| ^ | ||
| "Test_name.c", line 7: note: function "f(int *)" does not match because argument #1 does not match parameter | ||
| int f(int*); | ||
| ^ | ||
| "Test_name.c", line 6: note: function "f(int &&)" does not match because argument #1 does not match parameter | ||
| int f(int&&); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 16: error: no instance of overloaded function "g" matches the argument list | ||
| argument types are: ({...}) | ||
| int j = g({A{}}); // Likewise for a const lvalue reference. | ||
| ^ | ||
| "Test_name.c", line 9: note: function "g(int *)" does not match because argument #1 does not match parameter | ||
| int g(int*); | ||
| ^ | ||
| "Test_name.c", line 8: note: function "g(const int &)" does not match because argument #1 does not match parameter | ||
| int g(const int&); | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,24 @@ | ||
| fe_only -DTEST_NUMBER=3 -tused --c++11 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 15: error: no instance of overloaded function "f" matches the argument list | ||
| argument types are: ({...}) | ||
| int i = f({A{}}); // Error: cannot copy-list-initialize the temporary int. | ||
| ^ | ||
| "Test_name.c", line 7: note: function "f(int *)" does not match because argument #1 does not match parameter | ||
| int f(int*); | ||
| ^ | ||
| "Test_name.c", line 6: note: function "f(int &&)" does not match because argument #1 does not match parameter | ||
| int f(int&&); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 16: error: no instance of overloaded function "g" matches the argument list | ||
| argument types are: ({...}) | ||
| int j = g({A{}}); // Likewise for a const lvalue reference. | ||
| ^ | ||
| "Test_name.c", line 9: note: function "g(int *)" does not match because argument #1 does not match parameter | ||
| int g(int*); | ||
| ^ | ||
| "Test_name.c", line 8: note: function "g(const int &)" does not match because argument #1 does not match parameter | ||
| int g(const int&); | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,24 @@ | ||
| fe_only -DTEST_NUMBER=4 -tused --c++20 Test_name.c | ||
| "Test_name.c", line 15: error: no instance of overloaded function "f" matches the argument list | ||
| argument types are: ({...}) | ||
| int i = f({A{}}); // Error: cannot copy-list-initialize the temporary int. | ||
| ^ | ||
| "Test_name.c", line 7: note: function "f(int *)" does not match because argument #1 does not match parameter | ||
| int f(int*); | ||
| ^ | ||
| "Test_name.c", line 6: note: function "f(int &&)" does not match because argument #1 does not match parameter | ||
| int f(int&&); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 16: error: no instance of overloaded function "g" matches the argument list | ||
| argument types are: ({...}) | ||
| int j = g({A{}}); // Likewise for a const lvalue reference. | ||
| ^ | ||
| "Test_name.c", line 9: note: function "g(int *)" does not match because argument #1 does not match parameter | ||
| int g(int*); | ||
| ^ | ||
| "Test_name.c", line 8: note: function "g(const int &)" does not match because argument #1 does not match parameter | ||
| int g(const int&); | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,24 @@ | ||
| fe_only -DTEST_NUMBER=5 -tused --c++20 --gnu_version 160200 Test_name.c | ||
| "Test_name.c", line 15: error: no instance of overloaded function "f" matches the argument list | ||
| argument types are: ({...}) | ||
| int i = f({A{}}); // Error: cannot copy-list-initialize the temporary int. | ||
| ^ | ||
| "Test_name.c", line 7: note: function "f(int *)" does not match because argument #1 does not match parameter | ||
| int f(int*); | ||
| ^ | ||
| "Test_name.c", line 6: note: function "f(int &&)" does not match because argument #1 does not match parameter | ||
| int f(int&&); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 16: error: no instance of overloaded function "g" matches the argument list | ||
| argument types are: ({...}) | ||
| int j = g({A{}}); // Likewise for a const lvalue reference. | ||
| ^ | ||
| "Test_name.c", line 9: note: function "g(int *)" does not match because argument #1 does not match parameter | ||
| int g(int*); | ||
| ^ | ||
| "Test_name.c", line 8: note: function "g(const int &)" does not match because argument #1 does not match parameter | ||
| int g(const int&); | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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,24 @@ | ||
| fe_only -DTEST_NUMBER=6 -tused --c++20 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 15: error: no instance of overloaded function "f" matches the argument list | ||
| argument types are: ({...}) | ||
| int i = f({A{}}); // Error: cannot copy-list-initialize the temporary int. | ||
| ^ | ||
| "Test_name.c", line 7: note: function "f(int *)" does not match because argument #1 does not match parameter | ||
| int f(int*); | ||
| ^ | ||
| "Test_name.c", line 6: note: function "f(int &&)" does not match because argument #1 does not match parameter | ||
| int f(int&&); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 16: error: no instance of overloaded function "g" matches the argument list | ||
| argument types are: ({...}) | ||
| int j = g({A{}}); // Likewise for a const lvalue reference. | ||
| ^ | ||
| "Test_name.c", line 9: note: function "g(int *)" does not match because argument #1 does not match parameter | ||
| int g(int*); | ||
| ^ | ||
| "Test_name.c", line 8: note: function "g(const int &)" does not match because argument #1 does not match parameter | ||
| int g(const int&); | ||
| ^ | ||
|
|
||
| 2 errors detected in the compilation of "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.
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: 42624
Script executed:
Repository: edgcpp/compiler
Length of output: 42934
Script executed:
Repository: edgcpp/compiler
Length of output: 42821
Script executed:
Repository: edgcpp/compiler
Length of output: 14272
Script executed:
Repository: edgcpp/compiler
Length of output: 4426
Script executed:
Repository: edgcpp/compiler
Length of output: 14013
Allow conditionally explicit conversion templates in the tentative match.
For a dependent
explicit(true)conversion template,try_conversion_function_match_fullcan reject the specialization even whenCCO_ALLOW_EXPLICIT_CONV_FUNCTIONSis set. The probe can then select aggregate initialization and produce1instead of42.Honor the conversion flag
if ((orig_is_copy_initialization || (conv_context & CCO_IGNORE_EXPLICIT_MEMBERS)) && !boolean_converted_case && !(conv_context & CCO_IGNORE_EXPLICIT_MEMBERS) && + !(conv_context & CCO_ALLOW_EXPLICIT_CONV_FUNCTIONS) && rtsp->is_conditionally_explicit &&Add the example as a regression test.
Script executed:
Repository: edgcpp/compiler
Length of output: 9402
Script executed:
Repository: edgcpp/compiler
Length of output: 31142
Web query:
C++ draft over.match.ref explicit conversion function reference compatible derived return type direct initialization copy constructor parameterResult:
Web query:
C++ draft over.match.copy "When initializing a temporary object" "permissible types for explicit conversion functions" derivedResult:
Script executed:
Repository: edgcpp/compiler
Length of output: 754
Script executed:
Repository: edgcpp/compiler
Length of output: 30184
Script executed:
Repository: edgcpp/compiler
Length of output: 46249
Script executed:
Repository: edgcpp/compiler
Length of output: 36396
Script executed:
Repository: edgcpp/compiler
Length of output: 23566
Script executed:
Repository: edgcpp/compiler
Length of output: 22698
Web query:
C++20 N4861 over.match.copy "permissible types" "explicit conversion functions" derived first parameter constructorResult:
Allow explicit conversions returning a derived class
For a copy-constructor temporary,
try_conversion_function_match_fullrejects an explicit conversion returning a derived class. The tentative match can then select aggregate fallback and initializento1instead of42.Allow the derived return in this temporary-initialization case. Apply the same rule to the final constructor path without changing the narrower direct-reference-binding rule.