The following valid code snippet is rejected since at least gcc 2.95.3:

===================================
template<typename> struct A
{
    template<int> struct B;
    friend struct A::template B<0>;
};
===================================

The error message on mainline reads:

bugA.cc:4: error: expected identifier before ';' token
bugA.cc:4: error: friend declaration does not name a class or function

GCC also rejects

===================================
template<typename> struct A
{
    template<int> struct B {};
    A::template B<0> b;
};
===================================

with

bugB.cc:4: error: ISO C++ forbids declaration of 'B' with no type
bugB.cc:4: error: template-id 'B<0>' used as a declarator
bugB.cc:4: error: expected ';' before 'b'

Removing the redundant "template" keyword makes the code compile in both cases.

-- 
           Summary: Redundant "template" keyword rejected
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, monitored
          Severity: normal
          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=19501

Reply via email to