In the code snippet below the error messages for the template case
and the non-template case differ (the template case being worse):
================================
struct A
{
friend int A();
};
template<int> struct B
{
friend int B();
};
B<0> b;
================================
non-template part:
bug.cc:3: error: return type specification for constructor invalid
bug.cc:3: warning: member functions are implicitly friends of their class
template part:
bug.cc:8: error: return type specification for constructor invalid
bug.cc: In instantiation of 'B<0>':
bug.cc:11: instantiated from here
bug.cc:8: error: 'void B()' redeclared as different kind of symbol
^^^^^^^^
that's not a constructor
bug.cc:6: error: previous declaration of 'template<int <anonymous> > struct B'
This is present since at least gcc 2.95.3.
--
Summary: Error message for invalid friend declaration could be
improved
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18543