Opened 12 years ago

Closed 12 years ago

#5178 closed Bugs (fixed)

boost::exception uses invalid C++ code

Reported by: Chris Jefferson Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

boost::exception uses a

std::map<type_info_, shared_ptr<error_info_base> > in error_info_container_impl. This map is copied in clone(). However, type_info_ contains a member which is a reference, so it is not copyable.

The standard says that you can only copy a std::map<T,U> if both T and U are copyable. Some standard libraries don't make use of this requirement, but libc++ does.

The easiest fix to this would be to make type_info_ take it's reference member instead by pointer, and make it copyable.

Before I prepare a full patch, I wondered if anyone had any comments, as this is a fairly big change to boost::exception

Attachments (1)

info_patch.hpp (833 bytes ) - added by Chris Jefferson 12 years ago.
Patch to info.hpp, using new copy constructor

Download all attachments as: .zip

Change History (4)

comment:1 by Steven Watanabe, 12 years ago

Actually, the solution is simple:

  • Implement the copy constructor
  • Use it in clone

The standard only requires the template arguments to be CopyAssignable for assignment, not for copy construction.

by Chris Jefferson, 12 years ago

Attachment: info_patch.hpp added

Patch to info.hpp, using new copy constructor

comment:2 by Chris Jefferson, 12 years ago

You are right, that is much simpler, and I missed it. Thanks.

The attached patch does exactly this, and fixes all but one bug in libc++ boost::exception (which is a different problem). gcc darwin still passes all tests.

comment:3 by Emil Dotchevski, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.