Re: void pointer and map (fwd)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux