I keep getting weird warnings. I have isolated the problem to the following test-case source file:
When compiled withCode:#include <vector> class testclass { public: testclass(const testclass &o); // {}; }; void testfunc() { std::vector <std::vector<testclass> > testobj; testobj.push_back(std::vector<testclass>()); }
g++ -W -O2 -c C:\Rotzooi\test.cpp -o obj\test.o
I get the following errors:
(edited for readability)Code:stl_vector.h||In member function `std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = testclass, _Alloc = std::allocator<testclass>]':| stl_vector.h|715|warning: '__result' might be used uninitialized in this function| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h||In member function `void std::vector<_Tp, _Alloc>::_M_insert_aux (__gnu_cxx::__normal_iterator<typename _Alloc::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = std::vector<testclass, std::allocator<testclass> >, _Alloc = std::allocator<std::vector<testclass, std::allocator<testclass> > >]':| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function| stl_uninitialized.h||In function `void testfunc()':| stl_uninitialized.h|82|warning: '__cur' might be used uninitialized in this function|
I do notice I don't get any warnings when I give the constructors function definition right in the class declaration. Also, no warnings without the optimalisation flag (and obviously not without the -W flag). Is this something to be worried about? And why do I get these warnings? Any way to prevent them?
Thanks in advance. I'm really scratching my head at the moment.![]()



LinkBack URL
About LinkBacks



