This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

vector<T>::push_back()


Title: vector<T>::push_back()

Hello.

I noted, that when using the push_back(contst T) method of the vector<T> class, the linker is looking for some iostream functions - even though I don't use the "iostream" library in my program. Other methods don't cause this behaviour. This needn't be a bug, but it seems strange to me.

test.cpp:

   #include <vector>
   int main(int argc, char* argv[])
   {
      std::vector<long> vv;
      vv.push_back(2);
      return 0;
   }

When I don't have the appropriate lib-file with iostream functions in the searched path, the linker complains:

   test.o: In function `__malloc_alloc_template<0>::_S_oom_malloc(unsigned int)':
   test.o(.__malloc_alloc_template<0>::gnu.linkonce.t._S_oom_malloc(unsigned int)+0x1a): undefined reference to `endl(ostream &)'

   test.o(.__malloc_alloc_template<0>::gnu.linkonce.t._S_oom_malloc(unsigned int)+0x27): undefined reference to `cerr'
   test.o(.__malloc_alloc_template<0>::gnu.linkonce.t._S_oom_malloc(unsigned int)+0x2c): undefined reference to `ostream::operator<<(char const *)'

   test.o(.__malloc_alloc_template<0>::gnu.linkonce.t._S_oom_malloc(unsigned int)+0x37): undefined reference to `ostream::operator<<(ostream &(*)(ostream &))'

   collect2: ld returned 1 exit status

Best regards,
                        Martin.


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