This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: segmentation fault


Daniel Jacobowitz escribió:
On Sat, Nov 11, 2006 at 09:29:39PM +0100, Raúl Huertas wrote:
No. ;)
Maybe I'm wrong, but sptr is a pointer, so it uses 0x804b028 and 0x804b029.
The memory pointed by this pointer is the one that has size 16.

You're incorrect, in fact. The original poster's interpretation is reasonable, assuming that GDB has printed out the correct values of variables.

Yes, you are right, and I was incorrect:

struct servent
{
  char memory[16];
};

int main()
{
   servent * sptr1 = new servent;
   servent * sptr2 = new servent;
   servent * sptr3 = sptr1;
}

----------------
(gdb) p sptr1
$1 = (servent *) 0x804a008
(gdb) p sptr2
$2 = (servent *) 0x804a020
(gdb) p sptr3
$3 = (servent *) 0x804a008

gdb shows the content of the pointer, not the position of the pointer. My idiot error... :*)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]