public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94529] New: Wrong error message for template member function specialization
@ 2020-04-08  8:30 kunal.tyagi.3.1994 at gmail dot com
  2020-04-08 15:39 ` [Bug c++/94529] " redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: kunal.tyagi.3.1994 at gmail dot com @ 2020-04-08  8:30 UTC (permalink / raw)
  To: gcc-bugs

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; }

         ^                                  ~
```

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

end of thread, other threads:[~2023-07-07  8:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08  8:30 [Bug c++/94529] New: Wrong error message for template member function specialization kunal.tyagi.3.1994 at gmail dot com
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

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).