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]

-frepo g++ bug ?



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

--


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