直到脱离main函数的作用域,都没有发现d和a变为4(本次仅测试了d,但a也是一样的)
Code::Blocks中调试是这样,然后我查阅了相关的GDB中文手册,按照手册中说明的方法用图形终端调试,还是这样.
英文不是很好,去GDB官网查看,上面说如果是在发行版中,发现GDB的BUG应该首先向发行商报告,因为发行商很可能自己修改了GDB.
所以就来这里提问了,而且这里是中文,相比向GDB官方反馈,还是容易一些.
系统环境是Lubuntu 13.04.
以下是图形终端中的操作过程,其结果和Code::Blocks中的图形调试界面完全相同:
代码: 全选
test@atom-Lenovo:~/myprogram/cpp$ g++ -Wall -g -std=c++11 test.cpp
test.cpp: In function ‘int main()’:
test.cpp:4:16: warning: variable ‘b’ set but not used [-Wunused-but-set-variable]
test@atom-Lenovo:~/myprogram/cpp$ gdb a.out
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/test/myprogram/cpp/a.out...done.
(gdb) l
1 #include <iostream>
2 int main(void)
3 {
4 int a = 3, b = 4;
5 decltype(a) c = a;
6 decltype((b)) d = a;
7 ++c;
8 ++d;
9 }
(gdb) break 8
Breakpoint 1 at 0x80485a0: file test.cpp, line 8.
(gdb) r
Starting program: /home/test/myprogram/cpp/a.out
Breakpoint 1, main () at test.cpp:8
8 ++d;
(gdb) p a
$1 = 3
(gdb) p d
$2 = (int &) @0xbffff1b8: 3
(gdb) n
9 }
(gdb) p a
No symbol "a" in current context.
(gdb) p d
No symbol "d" in current context.
(gdb) q
A debugging session is active.
Inferior 1 [process 22906] will be killed.
Quit anyway? (y or n) y