This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: void pointer and map (fwd)
- From: Anitha Boyapati <anithab at sankhya dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 21 Dec 2007 19:33:16 +0530 (IST)
- Subject: Re: void pointer and map (fwd)
Hi,
On Fri, 21 Dec 2007, Andrew Haley wrote:
> Anitha Boyapati writes:
> >
> >
> > Below is a minimisation of a larger program (that may explain why the
> > objective of the progarm is not too clear). The essence is I am trying to
> > do a map find with a structure as key and the significant aspect of the
> > structure is - it has a void *. I expect the below progarm to print
> > nothing as s2 is not there on the map at all! There are 2 findings
> > however:
> >
> > 1. "Address found" is getting printed
> > 2. Segmentation fault occurs.
>
> You're passing an instance of Value to Map::value_type, which creates
> a pair instance by copying both the key and the value. Note that we
> now have two instances of Value, both of which are pointing to the
> same buf. operator delete will be called on both of these instances.
Right! I missed a copy constructor then. That solves it then. Thanks.
>
> Andrew.
>
>
--
Regards,
Anitha B
@S A N K H Y A