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

Bug#216234: g++-3.3: template function triggers syntax error



Package: g++-3.3
Version: 1:3.3.2-0pre5.0.1
Severity: normal
Tags: sid

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

The Intel compiler processes the code without any error (only
warnings because he doesn't like the extra semicolons).

Cheers
   Thimo

-- System Information:
Debian Release: testing/unstable
Architecture: alpha
Kernel: Linux riff 2.4.22riff #1 Mo Sep 29 22:54:24 CEST 2003 alpha
Locale: LANG=de_DE@euro, LC_CTYPE=de_DE@euro

Versions of packages g++-3.3 depends on:
ii  gcc-3.3                1:3.3.2-0pre5.0.1 The GNU C compiler
ii  gcc-3.3-base           1:3.3.2-0pre5.0.1 The GNU Compiler Collection (base 
ii  libc6.1                2.3.2-8           GNU C Library: Shared libraries an
ii  libstdc++5-3.3-dev     1:3.3.2-0pre5.0.1 The GNU Standard C++ Library v3 (d

-- no debconf information




Reply to: