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]

Re: c++/9460: parse error on template member function


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=9460

I am not absolutely sure there is no bug here. For example, look at the
following snippet:

------------
struct Foo
{
    template <typename T>
    void F1(void) {}
};

template <typename A>
struct Bar
{
   void F2(void)
   {
       Foo f;
       f.F1<int>();
   }

    template <typename T>
    void F1(void) {}
};

template Bar<int>;
------------

The previous snippet is accepted by G++ but it shouldn't since it's not
legal. The compiler is fooled by Bar::F1<> having the same name of
Foo::F1<>. Also the following code is accepted as well and should not:

------------
struct Foo
{
    template <typename T>
    void F1(void) {}
};

template <typename A>
struct Bar
{
   void F2(void)
   {
      Foo().F1<int>();
   }
};

template Bar<int>;
------------

since it's still missing the template keyword in the member template call.
So it's not a case of reject-legal, but of accept-illegal.

Giovanni Bajo


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