Bug when parsing template-functions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

The following code shows that g++ reports a syntax error if the
method-call is inside a template-function but not if it's inside a
normal function:

-- snip --
#include <iostream>

template <int dim>
class Entity {
public:
  template <class T>
  void print(T& bla) { std::cout << bla;};

  template <int i>
  int test() { return i; }

  int other() { return 1; }
};

void foo1() {
  Entity<1> e;

  // everything works
  e.other();
  e.print("test");
  e.test<1>();
};

template <int dim>
void foo2() {
  Entity<dim> e;

  // works like above
  e.other();
  e.print("test");

  // fails with syntax error
  e.test<1>();
};

int main () {  
};
-- snip --

riff /tmp> g++ -Wall temptest2.cc
temptest2.cc: In function `void foo2()':
temptest2.cc:33: error: syntax error before `)' token
riff /tmp> g++ --version
g++ (GCC) 3.3.2 (Debian)
...

(some comments on this may be found in my report to the Debian-BTS on
http://bugs.debian.org/216234). I'd like to forward this bug to the
GCC-bug-tracking-system but am not sure if this may be the known bug

-- snip --
Two stage lookup in templates is not implemented.

    [14.6] specifies how names are looked up inside a template. G++
    does not do this correctly, but for most templates this will not
    be noticeable.
-- snip --

mentioned on http://gcc.gnu.org/bugs.html#known

Please CC me on reply, I'm not subscribed to this list.

Cheers
   Thimo

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux