Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10751 closed Bugs (worksforme)

exception_detail::set_info should use make_shared

Reported by: Li Yinan <li_yinan@…> Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

info.hpp:170

            shared_ptr<error_info_tag_t> p( new error_info_tag_t(v) );

should be

            shared_ptr<error_info_tag_t> p = make_shared<error_info_tag_t>(v);

Change History (3)

comment:1 by Emil Dotchevski, 8 years ago

Resolution: worksforme
Status: newclosed

This doesn't seem like a bug to me.

comment:2 by Li Yinan <li_yinan@…>, 8 years ago

Sorry, but I think it will be less likely to have bad_alloc with make_shared.

comment:3 by Emil Dotchevski, 8 years ago

This isn't necessarily true: the free space may by fragmented and it is possible that two smaller allocations succeed while the single bigger allocation from make_shared fails.

Either way the program should be exception-safe in case adding error info throws.

Note: See TracTickets for help on using tickets.