Opened 13 years ago

Closed 12 years ago

#3856 closed Bugs (fixed)

ambiguities with make_shared() function pointers with C++0x

Reported by: Georg Fritzsche <georg.fritzsche@…> Owned by: Peter Dimov
Milestone: Boost 1.42.0 Component: smart_ptr
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

Trying to store a function pointer to make_shared<Arg1> results in ambiguity errors in gcc (4.3.) with C++0x support being enabled.

The following:

typedef boost::shared_ptr<int>(*FP)();
FP fp = boost::make_shared<int>;

leads to:

error: converting overloaded function ‘make_shared’ to type ‘class boost::shared_ptr<int> (*)()’ is ambiguous
boost_1_41_0/boost/smart_ptr/make_shared.hpp:100: error: candidates are: boost::shared_ptr<X> boost::make_shared() [with T = int]
boost_1_41_0/boost/smart_ptr/make_shared.hpp:138: error: boost::shared_ptr<X> boost::make_shared(Args&& ...) [with T = int, Args = ]

Attachments (1)

test_make_shared.cpp (163 bytes ) - added by Georg Fritzsche <georg.fritzsche@…> 13 years ago.
simple test case

Download all attachments as: .zip

Change History (5)

by Georg Fritzsche <georg.fritzsche@…>, 13 years ago

Attachment: test_make_shared.cpp added

simple test case

comment:1 by georg.fritzsche@…, 13 years ago

Component: Nonesmart_ptr
Owner: set to Peter Dimov

comment:2 by Peter Dimov, 13 years ago

I can remove the nullary overload, but this will make the test at source:trunk/libs/smart_ptr/test/make_shared_test.cpp#L57 to fail on gcc 4.3.x (and maybe some 4.4 versions, I haven't checked.)

comment:3 by Peter Dimov, 12 years ago

(In [62248]) Resolve the ambiguity between the zero argument make_shared and the variadic one. Refs #3856.

comment:4 by Peter Dimov, 12 years ago

Resolution: fixed
Status: newclosed

(In [63827]) Merge [62248] to release. Fixes #3856.

Note: See TracTickets for help on using tickets.