Opened 15 years ago

Closed 15 years ago

#954 closed Bugs (fixed)

boost::dynamic_properties has no copy-constructor

Reported by: gavinband@… Owned by: doug_gregor
Milestone: Component: property_map
Version: Boost Development Trunk Severity: Problem
Keywords: property map Cc:

Description

The class boost::dynamic_properties, defined in boost/dynamic_property_map.hpp, has no supplied copy-constructor or assignment operator. Therefore the compiler gives it one. Since dynamic_properties manipulates pointers to its stored dynamic_property_map objects, this supplied constructor is not valid and leads to a crash.

Here is a program which crashes in this way:

#include <boost/dynamic_property_map.hpp>

int main()
{
  std::map<long,long> my_map;
  boost::associative_property_map<std::map<long,long> > apm(my_map);
  boost::dynamic_properties dp;
  dp.property("property",apm);
  boost::dynamic_properties dp2(dp);
  // crash occurs when dp is destructed.
  return 0;
}

Change History (4)

comment:1 by gavinband@…, 15 years ago

Apologies, the component should be "property maps" not "building boost".

comment:2 by René Rivera, 15 years ago

Component: Building Boostproperty_map
Owner: set to Douglas Gregor
Severity: Showstopper

comment:3 by Marshall Clow, 15 years ago

Owner: changed from Douglas Gregor to doug_gregor

Assigned to "doug_gregor" instead of nonexistent user "dgregor"

comment:4 by Andrew Sutton, 15 years ago

Resolution: fixed
Severity: ShowstopperProblem
Status: newclosed
Version: release 1.34.0Boost Development Trunk

Added a new virtual clone() function (i.e., virtual copy constructor) to dynamic_property_map and its derived, template adaptor. This feature is used in the new copy constructor for dynamic_properties. Added a test for it in the unit test.

Note: See TracTickets for help on using tickets.