-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed as not planned
Closed as not planned
Copy link
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issueDoes the clang frontend diverge from edg compiler on this issuediverges-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 issuegenerated by fuzzerinvalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a buglambdaC++11 lambda expressionsC++11 lambda expressions
Description
Clang rejects following C++ code containing generic lambda in anonymous struct's member function, while both GCC and MSVC accept the same code. This affects all forms of generic lambdas like auto&x
, auto... x
.
- Here is the reproducer: https://godbolt.org/z/1ehMYbsT8
- Generated by fuzzer.
Program
typedef struct {
void foo() {
auto f = [](auto&& x) {};
f(f);
}
} Test;
Clang Output
<source>:1:15: error: anonymous non-C-compatible type given name for linkage purposes by typedef declaration after its linkage was computed; add a tag name here to establish linkage prior to definition
1 | typedef struct {
| ^
| Test
<source>:2:5: note: type is not C-compatible due to this member declaration
2 | void foo() {
| ^~~~~~~~~~~~
3 | auto f = [](auto&& x) {};
| ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | f(f);
| ~~~~~
5 | }
| ~
<source>:6:3: note: type is given name 'Test' for linkage purposes by this typedef declaration
6 | } Test;
| ^
1 error generated.
Compiler returned: 1
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issueDoes the clang frontend diverge from edg compiler on this issuediverges-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 issuegenerated by fuzzerinvalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a buglambdaC++11 lambda expressionsC++11 lambda expressions