This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: 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


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