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

* [Bug c++/94529] Wrong error message for template member function specialization
  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 ` redi at gcc dot gnu.org
  2020-04-08 15:42 ` [Bug c++/94529] [8/9/10 Regression] " redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-08 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-04-08
             Status|UNCONFIRMED                 |NEW

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

* [Bug c++/94529] [8/9/10 Regression] Wrong error message for template member function specialization
  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 ` redi at gcc dot gnu.org
  2020-04-08 15:49 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-08 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.4.7
            Summary|Wrong error message for     |[8/9/10 Regression] Wrong
                   |template member function    |error message for template
                   |specialization              |member function
                   |                            |specialization
      Known to fail|                            |10.0, 4.5.4, 8.3.0, 9.2.0

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The "saw 1 'template<>', need 2 for specializing a member function template"
note is completely bogus, confusing, and wasn't present in GCC 4.4, so I'm
marking this as a diagnostic regression.

We should drop the incorrect note in this situation, and adding Clang's note
about the *real* cause would be a nice bonus.

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

* [Bug c++/94529] [8/9/10 Regression] Wrong error message for template member function specialization
  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
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-08 15:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Started with r154518:

pt.c (determine_specialization): Give helpful error about missing "template<>".

        * pt.c (determine_specialization): Give helpful error about missing
        "template<>".

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

* [Bug c++/94529] [8/9/10 Regression] Wrong error message for template member function specialization
  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
                   ` (2 preceding siblings ...)
  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
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-30  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
            Version|unknown                     |9.3.0
   Target Milestone|---                         |8.5

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

* [Bug c++/94529] [8/9/10/11 Regression] Wrong error message for template member function specialization
  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
                   ` (3 preceding siblings ...)
  2020-04-30  7:22 ` rguenth at gcc dot gnu.org
@ 2021-04-08  5:01 ` jason at gcc dot gnu.org
  2021-04-08 11:59 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-08  5:01 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/94529] [8/9/10/11 Regression] Wrong error message for template member function specialization
  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
                   ` (4 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-08 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:ac24fa46e449fbff0ff571951cfcc78b8488f6e7

commit r11-8042-gac24fa46e449fbff0ff571951cfcc78b8488f6e7
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 8 01:03:28 2021 -0400

    c++: improve specialization mismatch diagnostic [PR94529]

    We were telling users they needed more template<> to specialize a member
    template in a testcase with no member templates.  Only produce that message
    if we actually see a member template, and also always print the candidates.

    gcc/cp/ChangeLog:

            PR c++/94529
            * pt.c (determine_specialization): Improve diagnostic.

    gcc/testsuite/ChangeLog:

            PR c++/94529
            * g++.dg/template/mem-spec2.C: New test.

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

* [Bug c++/94529] [8/9/10 Regression] Wrong error message for template member function specialization
  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
                   ` (5 preceding siblings ...)
  2021-04-08 11:59 ` cvs-commit at gcc dot gnu.org
@ 2021-04-08 11:59 ` jason at gcc dot gnu.org
  2021-05-14  9:53 ` [Bug c++/94529] [9/10 " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-08 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10/11 Regression]      |[8/9/10 Regression] Wrong
                   |Wrong error message for     |error message for template
                   |template member function    |member function
                   |specialization              |specialization
      Known to work|                            |11.0

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11 so far.

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

* [Bug c++/94529] [9/10 Regression] Wrong error message for template member function specialization
  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
                   ` (6 preceding siblings ...)
  2021-04-08 11:59 ` [Bug c++/94529] [8/9/10 " jason at gcc dot gnu.org
@ 2021-05-14  9:53 ` jakub at gcc dot gnu.org
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

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

* [Bug c++/94529] [9/10 Regression] Wrong error message for template member function specialization
  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
                   ` (7 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug c++/94529] [10 Regression] Wrong error message for template member function specialization
  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
                   ` (8 preceding siblings ...)
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:42 ` rguenth at gcc dot gnu.org
  2022-06-28 10:40 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug c++/94529] [10 Regression] Wrong error message for template member function specialization
  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
                   ` (9 preceding siblings ...)
  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
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug c++/94529] [10 Regression] Wrong error message for template member function specialization
  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
                   ` (10 preceding siblings ...)
  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
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.0
      Known to fail|                            |10.5.0

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 11.

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

* [Bug c++/94529] [10 Regression] Wrong error message for template member function specialization
  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
                   ` (11 preceding siblings ...)
  2023-07-07  8:48 ` rguenth at gcc dot gnu.org
@ 2023-07-07  8:48 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
.

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