This is the mail archive of the gcc@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]

Re: C++ automatic template instantiation?



  On Wednesday, 19 April 2000, Mike Stump wrote:
> It won't be without bug reports.  With bug reports it stands a chance
> at bug fixes.  Generally speaking, if you want to know if it works in
> a particular instance, you're going to have to try it.

Ok, here is another one, the one that makes gcc go into an infinite
loop:

First file, t.cc:

#include <stack>
void g();
template class stack<int>;
int main() { stack<int> s; g(); }

Second file, g.cc:

#include <stack>
template class stack<int>;
void g() { stack<int> s; }

Note that I terminated the loop with a ^C, that's how I ended up
seeing the actual multiple definition messages.

Tudor


[tudor@data]:~ $ c++ -frepo -c t.cc g.cc; c++ t.o g.o
collect: recompiling t.cc
collect: recompiling g.cc
collect: recompiling t.cc
collect: recompiling g.cc
collect: recompiling t.cc
collect: recompiling g.cc
collect: recompiling t.cc
collect: recompiling g.cc
collect: recompiling t.cc
collect: recompiling g.cc
 
[tudor@data]:~ $ g.o: In function `stack<int, deque<int, allocator<int>, 0> >::stack(void)':
g.o(.text+0x0): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::stack(void)'
t.o(.text+0x0): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::stack(deque<int, allocator<int>, 0> const &)':
g.o(.text+0xf4): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::stack(deque<int, allocator<int>, 0> const &)'
t.o(.text+0x104): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::empty(void) const':
g.o(.text+0x14c): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::empty(void) const'
t.o(.text+0x15c): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::size(void) const':
g.o(.text+0x170): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::size(void) const'
t.o(.text+0x180): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::top(void)':
g.o(.text+0x194): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::top(void)'
t.o(.text+0x1a4): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::top(void) const':
g.o(.text+0x1b8): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::top(void) const'
t.o(.text+0x1c8): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::push(int const &)':
g.o(.text+0x1dc): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::push(int const &)'
t.o(.text+0x1ec): first defined here
g.o: In function `stack<int, deque<int, allocator<int>, 0> >::pop(void)':
g.o(.text+0x200): multiple definition of `stack<int, deque<int, allocator<int>, 0> >::pop(void)'
t.o(.text+0x210): first defined here
t.o: In function `deque<int, allocator<int>, 0>::deque(deque<int, allocator<int>, 0> const &)':
t.o(.deque<int, allocator<int>, 0>::gnu.linkonce.t.(deque<int, allocator<int>, 0> const &)+0x107): undefined reference to `_Deque_base<int, allocator<int>, 0>::~_Deque_base(void)'
t.o: In function `deque<int, allocator<int>, 0>::push_back(int const &)':
t.o(.deque<int, allocator<int>, 0>::gnu.linkonce.t.push_back(int const &)+0x36): undefined reference to `deque<int, allocator<int>, 0>::_M_push_back_aux(int const &)'
t.o: In function `deque<int, allocator<int>, 0>::pop_back(void)':
t.o(.deque<int, allocator<int>, 0>::gnu.linkonce.t.pop_back(void)+0x2c): undefined reference to `deque<int, allocator<int>, 0>::_M_pop_back_aux(void)'
t.o: In function `deque<int, allocator<int>, 0>::~deque(void)':
t.o(.gnu.linkonce.t._._t5deque3ZiZt9allocator1ZiUi0+0x51): undefined reference to `_Deque_base<int, allocator<int>, 0>::~_Deque_base(void)'
t.o: In function `_Deque_base<int, allocator<int>, 0>::_Deque_base(allocator<int> const &, unsigned int)':
t.o(._Deque_base<int, allocator<int>, 0>::gnu.linkonce.t.(allocator<int> const &, unsigned int)+0x43): undefined reference to `_Deque_base<int, allocator<int>, 0>::_M_initialize_map(unsigned int)'
t.o: In function `deque<int, allocator<int>, 0>::deque(allocator<int> const &)':
t.o(.deque<int, allocator<int>, 0>::gnu.linkonce.t.(allocator<int> const &)+0x37): undefined reference to `_Deque_base<int, allocator<int>, 0>::~_Deque_base(void)'
collect2: ld returned 1 exit status
 
                                                                                                                                                              


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