-frepo g++ bug ?

Marat Ruvinov Marat.Ruvinov@msdw.com
Mon Feb 12 07:42:00 GMT 2001


Hello,

I wanted to force g++ to "automatically" instantiate template code using
the -frepo option described in the g++ manual.

> g++ -v
gcc version egcs-2.91.66

> g++ -frepo -c main.cc
> g++ -frepo -c templates.cc
> g++ main.o templates.o -o  main

main.o: In function 'main':
main.o (.text+0xb): undefined reference to 'A<int>::f(void)'
collect2: ld returned 1 exit status

// templates.h
//////////////////////////////////////////////////
template <class T>
class A {
public:
    void foo();    // declare foo()
};

// templates.cc
////////////////////////////////////////////////////
#include "templates.h"

template <class T>
void A<T>::foo() {}   // define foo()


// main.cc
//////////////////////////////////////////////////////
#include "templates.h"

main()
{
   A<int> obj;  // use the template
   obj.foo();  // A<int> not instantiated implicitly !!!!!!
}

Is this a bug? Or am a I doing something wrong?

Marat

--



More information about the Gcc-bugs mailing list