https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107151

            Bug ID: 107151
           Summary: Specializing a concepted template can emit bogus
                    assembly
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

#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

Reply via email to