Issue 110208
Summary clang-cl rejects "extern const __declspec(selectany)" variable as having "non-external linkage" when variable definition includes a struct definition
Labels new issue
Assignees
Reporter dunhor
    Wow that title is a mouthful. Here's a concrete example:
```c++
extern const __declspec(selectany) struct { int x; } foo = { 42 };
```
clang-cl gives the error:
```
> clang-cl main.cpp
main.cpp(2,25): error: 'selectany' can only be applied to data items with external linkage
    2 | extern const __declspec(selectany) struct { int x; } foo = { 42 };
      |                         ^
1 error generated.
```
Of course, if you give the struct its own definition, the code compiles fine:
```c++
struct bar { int x; };
extern const __declspec(selectany) bar foo = { 42 };
```
MSVC compiles both without issue.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to