-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second partydiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issuelambdaC++11 lambda expressionsC++11 lambda expressionsregression:19Regression in 19 releaseRegression in 19 release
Description
The following code compiles on both GCC and MSVC, but is refused by Clang (Godbolt link):
void func_1(auto)
{
[](auto) consteval
{
[](auto)
{
}(123);
};
}
auto func_2()
{
func_1(123);
}The error message:
<source>:6:9: error: no matching function for call to object of type '(lambda at <source>:6:9)'
6 | [](auto)
| ^~~~~~~~
7 | {
| ~
8 | }(123);
| ~
<source>:5:5: note: while substituting into a lambda expression here
5 | {
| ^
<source>:14:5: note: in instantiation of function template specialization 'func_1<int>' requested here
14 | func_1(123);
| ^
<source>:6:9: note: candidate template ignored: couldn't infer template argument 'auto:1'
6 | [](auto)
| ^
1 error generated.
From my experimentation:
func_1must be a function template;- The outer lambda must be immediate;
- The outer lambda must be either polymorphic or a lambda template;
- The inner lambda must be either polymorphic or a lambda template.
Note: the code from which I wrote this test-case is almost the same where I originally found #117676, so there could be some relation (or not).
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second partydiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issuelambdaC++11 lambda expressionsC++11 lambda expressionsregression:19Regression in 19 releaseRegression in 19 release
Type
Projects
Status
No status