[Bug c++/57014] pretty-printer prints anonymous for template-parameter with a name

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Aug 10 11:02:19 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-10

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed. Here's the relevant code:

template<int> struct B
{
  void F2(int, int, int = 0);
};

template<int N> void B<N>::F2(int = 0, int, int) {}



57014.C:6:22: error: redeclaration of ‘void B<<anonymous> >::F2(int, int, int)’
may not have default arguments [-fpermissive]
    6 | template<int N> void B<N>::F2(int = 0, int, int) {}
      |                      ^~~~
57014.C:6:40: error: default argument missing for parameter 2 of ‘void
B<<anonymous> >::F2(int, int, int)’
    6 | template<int N> void B<N>::F2(int = 0, int, int) {}
      |                                        ^~~
57014.C:6:31: note: ...following parameter 1 which has a default argument
    6 | template<int N> void B<N>::F2(int = 0, int, int) {}
      |                               ^~~~~~~


It would be nice if later declarations that name a template parameter could be
used to "fill in" any unnamed template parameters from the original
declaration, so that pretty printing isn't so ugly.


More information about the Gcc-bugs mailing list