Re: segmentation fault

Raúl Huertas
2006-11-11T21:02:43Z

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... :*)