Opened 15 years ago
Closed 15 years ago
#954 closed Bugs (fixed)
boost::dynamic_properties has no copy-constructor
| Reported by: | 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 , 15 years ago
comment:2 by , 15 years ago
| Component: | Building Boost → property_map | 
|---|---|
| Owner: | set to | 
| Severity: | → Showstopper | 
comment:3 by , 15 years ago
| Owner: | changed from to | 
|---|
Assigned to "doug_gregor" instead of nonexistent user "dgregor"
comment:4 by , 15 years ago
| Resolution: | → fixed | 
|---|---|
| Severity: | Showstopper → Problem | 
| Status: | new → closed | 
| Version: | release 1.34.0 → Boost 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.

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