From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19001 invoked by alias); 29 May 2008 06:21:32 -0000 Received: (qmail 18992 invoked by uid 22791); 29 May 2008 06:21:31 -0000 X-Spam-Check-By: sourceware.org Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.188) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 29 May 2008 06:21:08 +0000 Received: by nf-out-0910.google.com with SMTP id h3so1673948nfh.48 for ; Wed, 28 May 2008 23:21:05 -0700 (PDT) Received: by 10.210.130.14 with SMTP id c14mr2562258ebd.100.1212042065160; Wed, 28 May 2008 23:21:05 -0700 (PDT) Received: by 10.210.76.7 with HTTP; Wed, 28 May 2008 23:21:05 -0700 (PDT) Message-ID: <366c6f340805282321oeb69940u80c52ecb686bf6b6@mail.gmail.com> Date: Thu, 29 May 2008 17:58:00 -0000 From: "Peng Yu" To: gdb@sourceware.org Subject: No symbol "" in current context error for temporary variable in template class MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00171.txt.bz2 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 class A { public: A(int a) { T temp = a + 1; _a = temp + 1; } private: T _a; }; int main() { A 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 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)