A simple vector.push_back () causes some error in my code:
#include <vector> using namespace std; int main(int argc, const char *argv[]) { vector<unsigned> stack; stack.push_back(1); stack.push_back(1); //stack.size() becomes 467369971 after this stack.push_back(1); stack.push_back(1); ... more push_back()s ... return 0; }
I use GDB to test its behavior ... and it is strange that stack.size () goes wrong after the second push_back (). It will be 467369971! What could be wrong? I'm on Win7 64-bit and I'm using MinGW with g ++ 4.7.0
Below is the output of GDB:
(gdb) n 5 std::vector<unsigned> sta (gdb) n 6 stack.push_back(1); (gdb) display stack.size() 1: stack.size() = 0 (gdb) n 7 stack.push_back(1); 1: stack.size() = 1 (gdb) 8 stack.push_back(1); 1: stack.size() = 467369971
source share