Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

It is easier to write an incorrect program than understand a correct one.


rocksolid / Programming / (C++) My gdb went wrong

SubjectAuthor
o (C++) My gdb went wrongAnonymous

1
Subject: (C++) My gdb went wrong
From: Anonymous
Newsgroups: rocksolid.programming
Organization: Rocksolid Light
Date: Tue, 4 Jan 2022 16:15 UTC
Path: i2pn2.org!.POSTED.novabbs-org!not-for-mail
From: Anonym...@news.novabbs.org (Anonymous)
Newsgroups: rocksolid.programming
Subject: (C++) My gdb went wrong
Date: Tue, 4 Jan 2022 16:15:33 +0000
Organization: Rocksolid Light
Message-ID: <ae81fb4fa6e81a8aeb6cfa952505f481@news.novabbs.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="novabbs.org"; posting-host="novabbs-org:10.136.143.187";
logging-data="18622"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (www.novabbs.com/getrslight)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on novabbs.org
X-Rslight-Site: $2y$10$bWK6U5fpmFyanmeAVMEgoegt2rHLuJfKcIBTWwr1Ab.ugSneG81n2
View all headers
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


1
rocksolid light 0.7.2
clearneti2ptor