Issue |
152244
|
Summary |
[Clang] Clang rejects anonymous struct with generic lambda while GCC/MSVC accept
|
Labels |
clang
|
Assignees |
|
Reporter |
Xniao
|
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
```cpp
typedef struct {
void foo() {
auto f = [](auto&& x) {};
f(f);
}
} Test;
```
## Clang Output
```bash
<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
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs