[LLVMbugs] [Bug 8322] New: Clang 2.8 Compile fails with: "address of overloaded function 'XXX' cannot be converted to type 'YYY' ", succeeds in GCC 4.4.1
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Oct 6 20:07:29 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=8322
Summary: Clang 2.8 Compile fails with: "address of overloaded
function 'XXX' cannot be converted to type 'YYY' ",
succeeds in GCC 4.4.1
Product: clang
Version: 2.8
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: andy.somerville at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Created an attachment (id=5578)
--> (http://llvm.org/bugs/attachment.cgi?id=5578)
attachment version of failure example to make downloading easier
A somewhat complex code fails with:
error: address of overloaded function 'XXX' cannot be converted to type 'YYY'
Full details:
c++ src/failure.cpp
src/failure.cpp:19:65: error: address of overloaded function
'defaultMessageCreateFunction' cannot be converted to type
'function<shared_ptr<FailureCase::MessageType> ()> const'
const function<shared_ptr<M>(void)>& factory_fn =
defaultMessageCreateFunction<M>) {}
^
src/failure.cpp:30:13: note: in instantiation of default function argument
expression for 'init<FailureCase::MessageType>' required here
ops.template init<M>(bind(fp, obj, _1));
^
src/failure.cpp:43:13: note: in instantiation of function template
specialization 'Foo::subscribe<FailureCase::MessageType, FailureCase>'
requested here
foo.subscribe( &FailureCase::callback, this);
^
src/failure.cpp:19:52: note: passing argument to parameter 'factory_fn' here
const function<shared_ptr<M>(void)>& factory_fn =
defaultMessageCreateFunction<M>) {}
^
1 error generated.
src/failure.cpp (requires boost)
////////////////////////////////////////////////////////////////
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/make_shared.hpp>
#include <boost/bind.hpp>
using namespace boost;
template<typename M>
inline shared_ptr<M> defaultMessageCreateFunction()
{
return make_shared<M>();
}
struct SubscribeOptions
{
template<class M>
void init(const function<void (const shared_ptr<M const>&)>& _callback,
const function<shared_ptr<M>(void)>& factory_fn =
defaultMessageCreateFunction<M>) {}
};
class Foo
{
public:
template<class M, class T>
void subscribe( void(T::*fp)(const shared_ptr<M const>&), T* obj)
{
SubscribeOptions ops;
ops.template init<M>(bind(fp, obj, _1));
}
};
class FailureCase
{
class MessageType {};
typedef shared_ptr<MessageType const> MessageTypeConstPtr;
public:
FailureCase()
{
foo.subscribe( &FailureCase::callback, this);
}
void callback(const MessageTypeConstPtr& msg) {}
Foo foo;
};
int main()
{
FailureCase failureCase;
return 0;
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list