Hi, I have the following code. I try to print the variable temp in the constructor of A. But gdb can not do that. The error message is shown blow the C++ code.
According to the people from gdb mailing list, it is because that the compiler (g++) does not generate information for such variable in the debugging mode. Is it a bug of g++. BTW, I'm using g++ of the following version $ g++ --version g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Thanks, Peng template <typename T> class A { public: A(int a) { T temp = a + 1; _a = temp + 1; } private: T _a; }; int main() { A<double> a(1); } $ gdb main GNU gdb 6.4.90-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) start Breakpoint 1 at 0x400510: file main.cc, line 13. main () at main.cc:13 13 A<double> a(1); (gdb) s A (this=0x7fff250d7080, a=1) at main.cc:5 5 T temp = a + 1; (gdb) n 6 _a = temp + 1; (gdb) p temp No symbol "temp" in current context. (gdb)