Hi,
I bring the following code in the debugger:
 0  //-------------------------------------------------
 1  class F {
 2  public:
 3     int m_F;
 4     //-------
 5     F(int x)  : m_F(x) // constructor
 6     { }
 7     F(const F& f) :  m_F(f.m_F) // copy constructor
 8     { }
 9  };
10
11  int  getMember(F f)     // NOTE:  an object is passed, not a
reference
12  {
13     return f.m_F;
14  }
15
16  int main()
17  {
18    F f1(3);
19    int i = getMember(f1);
20    return 0;
21  }
22
23  //----------------------------------------------

As I step through main, line 19 executes correctly, and "i" contains 3
as expected.
Then I invoke "getMember()"  from the debugger, and the program under
the debugger receives SIGSEGV:
(gdb)  print   getMember(f1)
Program received signal SIGSEGV, Segmentation fault.
getMember (f1=Cannot access memory at address 0x3) at f.cc:15
The program being debugged was signaled while in a function called
from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (getMember(F))
will be abandoned.
------------------------------------------------------------------------------
1. If "getMember()" takes reference to F, everything is fine when
"getMember()" is called from gdb.
2. If I use C instead of C++, and struct, again everything is fine.
3. The system is   (uname -a)
     Linux belgrade 2.4.21-50.ELsmp #1 SMP Tue May 8 17:10:20 EDT 2007
x86_64 x86_64 x86_64 GNU/Linux
4. The compiler is gcc.
5. I tried using gdb 6.3 and 6.8 (the newest), and both behave
identically.

Thanks, Drazen
_______________________________________________
bug-gdb mailing list
bug-gdb@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gdb

Reply via email to