A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/99825 below:

Unexpected internal linkage of const/constexpr variable within extern "C++" · Issue #99825 · llvm/llvm-project · GitHub

clang rejects the following with error: declaration of 'x' with internal linkage cannot be exported:

export module mod;

extern "C++"
{
    export constexpr auto x = 10;
}

Compiler explorer: https://godbolt.org/z/a6nhazoKr

According to [basic.link] 3.2, const (or constexpr ) 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 of extern "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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4