Thread View: rocksolid.programming
1 messages
1 total messages
Started by Anonymous@news.n
Tue, 04 Jan 2022 16:15
(C++) My gdb went wrong
Author: Anonymous@news.n
Date: Tue, 04 Jan 2022 16:15
Date: Tue, 04 Jan 2022 16:15
32 lines
626 bytes
626 bytes
In the following code line 7, q[0] should be 1, but gdb claim that q[0] = 0. Can you plz explain what happened? It's GNU gdb (GDB) 11.1 (gdb) list 1 #include <cstdio> 2 #include <deque> 3 4 int main() { 5 std::deque<int> q; 6 q.push_front(1); 7 printf("%dn", q[0]); 8 return 0; 9 } (gdb) b 7 Breakpoint 1 at 0x1227: file /tmp/a.cpp, line 7. (gdb) r Starting program: /tmp/a Breakpoint 1, main () at /tmp/a.cpp:7 7 printf("%dn", q[0]); (gdb) p q[0] $1 = 0 (gdb) n 1 8 return 0; quit) A debugging session is active. Inferior 1 [process 115399] will be killed. Quit anyway? (y or n) y -- Posted on Rocksolid Light
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads