This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11715] New: Error with template keyword in a non-dependent type


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Error with template keyword in a non-dependent type
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Keywords: rejects-valid
          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

The following valid code (from PR 10398) is rejected
by g++ since at least gcc 2.95.x:

----------------------------------------------
struct A
{
    template <typename> struct B {};
};

template <typename T> struct C
{
    C() { A::template B<T> b; }
};

C<void> c;
----------------------------------------------

The error message is:

bug.cc: In constructor `C<T>::C()':
bug.cc:8: error: expected `;'
bug.cc: In constructor `C<T>::C() [with T = void]':
bug.cc:11:   instantiated from here
bug.cc:8: error: `B' undeclared (first use this function)
bug.cc:8: error: (Each undeclared identifier is reported only once for each 
   function it appears in.)

If one removes the "template" keyword in line 8 or adds
a typename before "A::template", the code compiles.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]