bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nested classes incorrectly printed


From: Volker Ernst
Subject: nested classes incorrectly printed
Date: Thu, 31 May 2001 10:12:34 -0400

In the following example two classes have a nested class with the same
name. Gdb incorrectly prints the contents of the nested class.

Please let me know if there is a work around to this or if it has
already been reported. I searched the mailing list archives and could
not find any mention of this problem.

Thanks,
Stuart Whitman


bash$ cat main.cc
class A {

        struct I;

        I * d_i;
public:
        A ();
};

struct A::I {
        int d_v;
};

A::A()
{ d_i = new I(); d_i->d_v = 5; }

class B {

        struct I;
        I* d_i;

public:
        B ();
};

struct B::I {
        double d_v;
};

B::B()
{ d_i = new I(); d_i->d_v = 1.0; }

main () 
{
        A a;
        B b;
}

bash$ gcc --version
2.95.3
bash$ gcc -g main.cc -o main.exe
bash$ /usr/local/bin/gdb main.exe
GNU gdb 5.0
Copyright 2000 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 "i686-pc-linux-gnu"...
(gdb) break main
Breakpoint 1 at 0x80492ae: file main.cc, line 35.
(gdb) run
Starting program: /export/home/stu/storm/src/data/gulf/test/main.exe 

Breakpoint 1, main () at main.cc:35
35              A a;
(gdb) n
36              B b;
(gdb) n
37      }
(gdb) print * a.d_i
$1 = {d_v = 5}
(gdb) print * b.d_i
$2 = {d_v = 0}
(gdb) ptype a.d_i
type = class I {
  public:
    int d_v;

    I & operator=(A::I const &);
    I(A::I const &);
    I(void);
} *
(gdb) ptype b.d_i
type = class I {
  public:
    int d_v;

    I & operator=(A::I const &);
    I(A::I const &);
    I(void);
} *
(gdb) quit
The program is running.  Exit anyway? (y or n) y
bash$ 
-- 
Stuart Whitman          Emergent Information Technologies, Inc.
     703 645 8445       Metro Place
Fax: 703 641 7172       2600 Park Tower Drive, Suite 1000
                        Vienna, VA 22180



reply via email to

[Prev in Thread] Current Thread [Next in Thread]