-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Unexpected internal linkage of const/constexpr variable within extern "C++" #99825
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:modules
C++20 modules and Clang Header Modules
constexpr
Anything related to constant evaluation
Comments
This was referenced Jul 21, 2024
@llvm/issue-subscribers-clang-frontend Author: Cameron Angus (kamrann)
clang rejects the following with `error: declaration of 'x' with internal linkage cannot be exported`:
```
export module mod;
extern "C++"
|
@llvm/issue-subscribers-clang-modules Author: Cameron Angus (kamrann)
clang rejects the following with `error: declaration of 'x' with internal linkage cannot be exported`:
```
export module mod;
extern "C++"
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:modules
C++20 modules and Clang Header Modules
constexpr
Anything related to constant evaluation
clang rejects the following with
error: declaration of 'x' with internal linkage cannot be exported
:Compiler explorer: https://godbolt.org/z/a6nhazoKr
According to [basic.link] 3.2,
const
(orconstexpr
) implies internal linkage for a namespace scope variable, with some exceptions, and 3.2.1 states that one such exception is if the declaration is in the purview of a module interface. clang appears to respect this generally, but in the case ofextern "C++"
it seems to not apply this exception, as if it considers the contents of such a block to not be part of the module's purview. This feels like a corner case, since obviously the symbols are not attached to the module; but the purview is nonetheless defined as all tokens following the module declaration and I can't see anywhere that states a linkage block is exempt.Note that MSVC accepts the code.
The text was updated successfully, but these errors were encountered: