public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kunal.tyagi.3.1994 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94529] New: Wrong error message for template member function specialization Date: Wed, 08 Apr 2020 08:30:59 +0000 [thread overview] Message-ID: <bug-94529-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94529 Bug ID: 94529 Summary: Wrong error message for template member function specialization Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kunal.tyagi.3.1994 at gmail dot com Target Milestone: --- [Relevant godbolt](https://godbolt.org/z/trqEMV) Snippet: ``` template <class T> struct foo { // the issue is const here void bar(T& foobar) const { foobar = 0; } }; template <> void foo<int>::bar(int& foobar) { foobar = 9; } ``` GCC (trunk) gives the error message: ``` <source>:8:1: error: template-id 'bar<>' for 'void foo<int>::bar(int&)' does not match any template declaration 8 | foo<int>::bar(int& foobar) { foobar = 9; } | ^~~~~~~~ <source>:8:1: note: saw 1 'template<>', need 2 for specializing a member function template ``` A better error message is reported by clang (3.5 onwards): ``` <source>:8:11: error: out-of-line definition of 'bar' does not match any declaration in 'foo<int>' foo<int>::bar(int& foobar) { foobar = 9; } ^~~ <source>:4:10: note: member declaration does not match because it is const qualified void bar(T& foobar) const { foobar = 0; } ^ ~ ```
next reply other threads:[~2020-04-08 8:30 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-08 8:30 kunal.tyagi.3.1994 at gmail dot com [this message] 2020-04-08 15:39 ` [Bug c++/94529] " redi at gcc dot gnu.org 2020-04-08 15:42 ` [Bug c++/94529] [8/9/10 Regression] " redi at gcc dot gnu.org 2020-04-08 15:49 ` redi at gcc dot gnu.org 2020-04-30 7:22 ` rguenth at gcc dot gnu.org 2021-04-08 5:01 ` [Bug c++/94529] [8/9/10/11 " jason at gcc dot gnu.org 2021-04-08 11:59 ` cvs-commit at gcc dot gnu.org 2021-04-08 11:59 ` [Bug c++/94529] [8/9/10 " jason at gcc dot gnu.org 2021-05-14 9:53 ` [Bug c++/94529] [9/10 " jakub at gcc dot gnu.org 2021-06-01 8:17 ` rguenth at gcc dot gnu.org 2022-05-27 9:42 ` [Bug c++/94529] [10 " rguenth at gcc dot gnu.org 2022-06-28 10:40 ` jakub at gcc dot gnu.org 2023-07-07 8:48 ` rguenth at gcc dot gnu.org 2023-07-07 8:48 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94529-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).