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

            Bug ID: 85604
           Summary: Default template arguments in friend class template
                    declarations should not be allowed
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adr26__gcc at nunsway dot co.uk
  Target Milestone: ---

template <int A, bool L> struct Template_Class;

struct Other_Struct
{
   template <int A, bool L = (A < 42)> friend struct Template_Class;
};

template <int A, bool>
struct Template_Class
{
};

template <>
struct Template_Class<0>
{
};

Per [temp.param]/12:

"A default template-argument shall not be specified in a friend class template
declaration."

All versions of G++ since at least 4.1.2 accept the code above.

Clang++ correctly rejects this code:

<source>:5:26: error: default template argument not permitted on a friend
template
   template <int A, bool L = (A < 42)> friend struct Template_Class;
                         ^   ~~~~~~~~

<source>:14:8: error: too few template arguments for class template
'Template_Class'
struct Template_Class<0>
       ^

<source>:9:8: note: template is declared here
struct Template_Class
       ^

https://godbolt.org/g/Tvf7Fr

Reply via email to