public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107151] New: Specializing a concepted template can emit bogus assembly
@ 2022-10-04 12:02 blubban at gmail dot com
  2022-10-05  9:05 ` [Bug c++/107151] " marxin at gcc dot gnu.org
  2022-10-05  9:10 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: blubban at gmail dot com @ 2022-10-04 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-05  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 12:02 [Bug c++/107151] New: Specializing a concepted template can emit bogus assembly blubban at gmail dot com
2022-10-05  9:05 ` [Bug c++/107151] " marxin at gcc dot gnu.org
2022-10-05  9:10 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).