Issue 114681
Summary storage specifiers not respected on specialized template constexpr variables yet warning is thrown
Labels new issue
Assignees
Reporter jcelerier
    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.

```c++
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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to