#include <cstdio> #include <concepts> template <typename T> void fun(T); template <> void fun(char c) { std::puts("foo<char>()"); } template <std::integral I> void fun(I i) { std::puts("foo<std::integral>()"); } int main() { fun<char>(' '); } Compile with -std=c++20. Result: /tmp/cctfBAWi.s: Assembler messages: /tmp/cctfBAWi.s:63: Error: symbol `_Z3funIcEvT_' is already defined /tmp/cctfBAWi.s: Error: .size expression for _Z3funIcEvT_ does not evaluate to a constant Expected: Prints foo<char>(), or at least a less cryptic error. With -O2, GCC only emits one _Z3funIcEvT_, but the resulting program prints foo<std::integral>(). https://godbolt.org/z/axvdbK1Eh Clang and MSVC have similar bugs: https://github.com/llvm/llvm-project/issues/58142 https://developercommunity.visualstudio.com/t/Template-explicit-specializationconcept/10012835
Note clang rejects the code: clang++ pr107151.C -c -std=c++20 -S pr107151.C:14:6: error: definition with same mangled name '_Z3funIcEvT_' as another definition void fun(I i) ^ pr107151.C:8:6: note: previous definition is here void fun(char c) ^ 1 error generated.
I think this is PR 100825