Code:
#include <vector> using namespace std; int main() { vector<int> beans; beans.resize(5); beans[3] = 4; beans [4] = 66; }
g++ -g 156.cpp
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 SKIPPED OUT WARRANT INFO HERE Reading symbols from /badcode/a.out...done. (gdb) break 156.cpp:10 Breakpoint 1 at 0x4008e6: file 156.cpp, line 10. (gdb) run Starting program: /badcode/a.out Breakpoint 1, main () at 156.cpp:10 10 beans [4] = 66; (gdb) print beans[3] $2 = (int &) @0x60401c: 4 (gdb) print beans[4] $3 = (int &) @0x604020: 0
Code:
Build command: gdb debugging session: