-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationAnything related to constant evaluation
Description
Problem:
- Given a template static constexpr variable in a .hpp, along with some specializations, clang, unlike MSVC and GCC emits non-weak symbols in all the TUs which causes duplicate symbol link errors.
template <typename T>
static const constexpr std::nullptr_t my_map = nullptr;
template <>
// gcc, msvc -> no duplicate symbol errors; all is fine
// clang 10 .. 19 -> link errors due to duplicate symbols
const constexpr int my_map<int> = 1;
template <>
// gcc, msvc -> fail to compile
// clang 10 .. 18 -> ok
// clang 19 -> throws a warning here but still does not respect the original static storage class and behaves like previous clang versions in terms of emitted symbols.
static const constexpr int my_map<float> = 2;- If the specializations are marked static, then clang does not cause the duplicate symbol error anymore. But clang-19 now warns: "explicit specialization cannot have a storage class [-Wexplicit-specialization-storage-class]_" despite honoring it.
Full repro: https://gcc.godbolt.org/z/3cqnonv4Y
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationAnything related to constant evaluation