egcs bug with -frepo and function template args

Ken McMillan mcmillanATCadence.COM
Tue Sep 14 17:24:00 GMT 1999


The -frepo option in egcs does not seem to cause templates whose
parameters are functions to be instantiated. Here is a short program
demonstrating this:

template <int f(int)>
class foo {
public:
  foo(){}
  virtual ~foo(){}
  int app(int i){return f(i);}
};

int fun(int x){return x + x;}

main(){
  foo<fun> x;
  x.app(1);
}

If this program is compiled as follows:

	g++ g++bug.cc

it works. On the other hand, if compiled as follows:

g++ -c g++bug.cc -frepo
g++ g++bug.o

you get the following output:

g++bug.o: In function `foo<&fun(int)>::foo(void)':
g++bug.o(.gnu.linkonce.t.__t3foo1PFi_i7fun__Fi+0x8): undefined reference to `foo<&fun(int)> virtual table'
g++bug.o: In function `foo<&fun(int)>::~foo(void)':
g++bug.o(.gnu.linkonce.t._._t3foo1PFi_i7fun(int)+0xd): undefined reference to `foo<&fun(int)> virtual table'
collect2: ld returned 1 exit status

g++ version is:

$ g++ --version
egcs-2.91.66

By the way, any hints on how to work around this problem would be
appreciated. When using -frepo, is there a way to force the compiler
to generate a virtual table for a given class?

	Best Regards -- Ken McMillan


More information about the Gcc-bugs mailing list