This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
-frepo g++ bug ?
- To: bug-gcc at gnu dot org, bug-g++ at gnu dot org
- Subject: -frepo g++ bug ?
- From: Marat Ruvinov <Marat dot Ruvinov at msdw dot com>
- Date: Mon, 12 Feb 2001 10:39:37 -0500
- Organization: Morgan Stanley Dean Witter & Co.
- Reply-To: Marat dot Ruvinov at msdw dot com
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
--