Skip to content
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

[C++20] [Modules] Incorrect linkage for in-class static data member #78382

Open
ChuanqiXu9 opened this issue Jan 17, 2024 · 2 comments
Open

[C++20] [Modules] Incorrect linkage for in-class static data member #78382

ChuanqiXu9 opened this issue Jan 17, 2024 · 2 comments
Assignees
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@ChuanqiXu9
Copy link
Member

See:

// a.cppm
export module a;
export struct A {
  static constexpr int table[] = {43, 44, 45};
};

According to https://eel.is/c++draft/class.static.data#6, the linkage of A::table should be the same with the A, which has external linkage instead of inline linkage. So we should be able to see its definition in a.o. But it is not true:

clang++ -std=c++20 a.cppm -emit-llvm -S -o -

Then we can't see the definition for A::table. It shows we didn't handle the linkage for A::table correctly.

@ChuanqiXu9 ChuanqiXu9 added the clang:modules C++20 modules and Clang Header Modules label Jan 17, 2024
@ChuanqiXu9 ChuanqiXu9 self-assigned this Jan 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2024

@llvm/issue-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)

See:
// a.cppm
export module a;
export struct A {
  static constexpr int table[] = {43, 44, 45};
};

According to https://eel.is/c++draft/class.static.data#6, the linkage of A::table should be the same with the A, which has external linkage instead of inline linkage. So we should be able to see its definition in a.o. But it is not true:

clang++ -std=c++20 a.cppm -emit-llvm -S -o -

Then we can't see the definition for A::table. It shows we didn't handle the linkage for A::table correctly.

@ChuanqiXu9
Copy link
Member Author

ChuanqiXu9 commented Jan 17, 2024

Wait. This is not a clear problem. I just noticed that there is no inline linkage in the spec. inline linkage is a concept in clang. So we can't explain the spec with the concept in clang. Then while we can say the current behavior doesn't violate the spec, there are some related discussion in itanium-cxx-abi/cxx-abi#170.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

2 participants