$ cat t.cc
class BaseSubmit
{
    template<class T> friend class PeriodicSubmit;
};

template<class ID>
class ValuesSubmit 
{
    template<class T> friend class PeriodicSubmit;
};

class A;
class MultiSubmit : public ValuesSubmit<A>
{
};

$ g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /tools/inst/gcc-4.1.1/configure --prefix=/tools/pkg/gcc/4.1.1
--enable-languages=c,c++ --disable-threads
Thread model: single
gcc version 4.1.1

$ g++ -c -o t.o t.cc
t.cc: In instantiation of 'ValuesSubmit<A>':
t.cc:13:   instantiated from here
t.cc:8: error: declaration of template 'template<class T> struct
PeriodicSubmit'
t.cc:3: error: conflicts with previous declaration 'template<class T> struct
PeriodicSubmit'
t.cc:8: error: declaration of 'template<class T> struct PeriodicSubmit'
t.cc:3: error: conflicts with previous declaration 'template<class T> struct
PeriodicSubmit'


Makeing BaseSubmit to a class template lets this error disappear.

The same if you add 'template<class T> class PeriodicSubmit;' as the first
line.

Note that there is a minor additional error.  The line number t.cc:8 is wrong.
It should be t.cc:9.


-- 
           Summary: multiple template friend compile error
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joerg dot richter at pdv-fs dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28025

Reply via email to