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++/11814] Code with missing "template" keyword wrongly accepted


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11814

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org
      Known to work|                            |7.0
         Resolution|---                         |FIXED
      Known to fail|                            |3.3, 4.5.3, 4.8.3, 4.9.3,
                   |                            |5.3.0, 6.3.0

--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
With the current trunk of GCC 7.0 the test cases are rejected as expected (GCC
6 still accepts it).  Closing as fixed.

$ cat t.C && gcc -O2 -S -Wall -Wextra t.C
template <typename> struct A
{
    template <typename> void foo();
};

template <typename T> struct B
{
    template <int> void foo()
    {
        A<T>* p;
        p->foo<int>(); // wrong: should be "p->template foo<int>();"
    }
};
t.C: In member function ‘void B<T>::foo()’:
t.C:11:16: error: expected primary-expression before ‘int’
         p->foo<int>(); // wrong: should be "p->template foo<int>();"
                ^~~
t.C:11:16: error: expected ‘;’ before ‘int’

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