From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25B243858407; Tue, 4 Oct 2022 12:02:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25B243858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664884950; bh=P9M/IMs2exVXAMlv5ce/3aynzIuPDVj/jGrUgw7PKo4=; h=From:To:Subject:Date:From; b=JHqK/8xOwKACmr5varUQm9LvCQIMlMHfNJ9M3s7dAWDUTKeWAD9z0hkWCiVXBPDUt BmVixPHrPg5fScLfLfX3AnH6ZgmBvLoJLi40F3YHEfWCEGbR8V9Jksp7dmh2GvDo/H kGEKgn/h+EMqFkV+9lYk5u8gp33ZvF2/i48xuRBo= From: "blubban at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107151] New: Specializing a concepted template can emit bogus assembly Date: Tue, 04 Oct 2022 12:02:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: blubban at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107151 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 #include template void fun(T); template <> void fun(char c) { std::puts("foo()"); } template void fun(I i) { std::puts("foo()"); } int main() { fun(' '); } Compile with -std=3Dc++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(), or at least a less cryptic error. With -O2, G= CC only emits one _Z3funIcEvT_, but the resulting program prints foo(). 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-specializat= ionconcept/10012835=