public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101811] New: Error not helpful for misplaced 'template'
@ 2021-08-07  9:26 tobi at gcc dot gnu.org
  2021-08-09  9:37 ` [Bug c++/101811] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tobi at gcc dot gnu.org @ 2021-08-07  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101811
           Summary: Error not helpful for misplaced 'template'
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tobi at gcc dot gnu.org
  Target Milestone: ---

This is a bad error message that caught my eye while refactoring some code
(https://godbolt.org/z/558vM4Wb3):

struct X {
    void f();
};

template<int i>  // this line should not be here
void X::f()
{}

gives:


<source>:6:6: error: no declaration matches 'void X::f()'
    6 | void X::f()
      |      ^
<source>:2:10: note: candidate is: 'void X::f()'
    2 |     void f();
      |          ^
<source>:1:8: note: 'struct X' defined here
    1 | struct X {
      |        ^

Note that the error message doesn't actually include what's wrong and so it is
fairly confusing until you actually look at the code.

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

end of thread, other threads:[~2021-08-10 11:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-07  9:26 [Bug c++/101811] New: Error not helpful for misplaced 'template' tobi at gcc dot gnu.org
2021-08-09  9:37 ` [Bug c++/101811] " redi at gcc dot gnu.org
2021-08-10  4:57 ` tobi at gcc dot gnu.org
2021-08-10 10:45 ` redi at gcc dot gnu.org
2021-08-10 11:32 ` tobi at gcc dot gnu.org
2021-08-10 11:41 ` redi at gcc dot gnu.org
2021-08-10 11:51 ` tobi 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).