hagerman@MAXWELL.ECE.CMU.EDU (John Hagerman) (06/04/89)
This is on a VAXstation 3200 running BSD 4.3, using g++ version 1.35.0
and GDB 3.1.2.
Consider the following C++ program:
#include <stream.h>
class Simple
{
int i;
public:
Simple(int i_init) { i = i_init; }
int GetI() { return i; }
}
main()
{
Simple s_real(5);
Simple &s_ref = s_real;
cout << s_real.GetI() << "\n";
cout << s_ref.GetI() << "\n";
exit(0);
}
When compiled and run, it produces two 5's as expected. When in GDB,
however, applying the member function works for the object but not for
the object reference:
...
Bpt 1, main (1, 2147477544, 2147477552) (gdb-bug.C line 14)
(gdb) n
(gdb) print s_real.GetI()
$1 = 5
(gdb) print s_ref.GetI()
$2 = 2147477444
(gdb)
- John