public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Why g++ does not emit any information for a local variable in a template class member function?
@ 2008-06-03 22:42 Peng Yu
  0 siblings, 0 replies; only message in thread
From: Peng Yu @ 2008-06-03 22:42 UTC (permalink / raw)
  To: gcc

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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-03 22:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-03 22:42 Why g++ does not emit any information for a local variable in a template class member function? Peng Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).