This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
No symbol "<val>" in current context error for temporary variable in template class
- From: "Peng Yu" <pengyu dot ut at gmail dot com>
- To: gdb at sourceware dot org
- Date: Thu, 29 May 2008 01:21:05 -0500
- Subject: No symbol "<val>" in current context error for temporary variable in template class
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. Would you please let me know how to make it work?
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)