Opened 9 years ago

#8689 new Bugs

Solaris: make_shared<const T> compile error

Reported by: matthew.bergin@… Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.51.0 Severity: Problem
Keywords: make_shared Cc:

Description

Compile this with Forte 11 (Sun C++ 5.8 Patch 121017-08 2006/12/06):

#include <boost/make_shared.hpp>
struct Foo { virtual ~Foo() {} };
void f() { boost::make_shared<const Foo>(); }

Compiler error is:

"/usr/local/include/boost/smart_ptr/make_shared.hpp", line 60: Error: Non-const function Foo::__SLIP.DELETER__C() called for const object.
"/usr/local/include/boost/smart_ptr/make_shared.hpp", line 86:     Where: While instantiating "boost::detail::sp_ms_deleter<const Foo>::destroy()".
"/usr/local/include/boost/smart_ptr/make_shared.hpp", line 86:     Where: Instantiated from boost::make_shared<const Foo>().
"test.cpp", line 3:     Where: Instantiated from non-template code.

Further testing shows the compiler incorrectly refuses to compile an explicit destructor call on any const T* with a virtual destructor.

Would it be worth explicitly removing const from sp_ms_deleter's template parameter?

Attachments (1)

make_shared_const.patch (573 bytes ) - added by matthew.bergin@… 9 years ago.

Download all attachments as: .zip

Change History (1)

by matthew.bergin@…, 9 years ago

Attachment: make_shared_const.patch added
Note: See TracTickets for help on using tickets.