I have a code (usage of C++ binding for the Squirrel language in the Code::Blocks IDE) that cannot be compiled with g++ from 4.1.1 (from FC devel) and 4.2.0 (20060729), but can be compiled with 3.2, 3.4 and 4.0 (all on Redhat/Fedora).
The output from the compiler is -- scriptbindings.cc: In static member function static void SqPlus::ReturnSpecialization<RT>::Call(Callee&, RT (Callee::*)(P1)const) [with Callee = Base, P1 = const String&, RT = const String&]: scriptbindings.cc:55: instantiated from void SqPlus::Call(Callee&, RT (Callee::*)(P1)const) [with Callee = Base, RT = const String&, P1 = const String&] scriptbindings.cc:60: instantiated from void SqPlus::RegisterInstance(Callee&, Func) [with Callee = Base, Func = const String& (Base::*)(const String&)const] scriptbindings.cc:69: instantiated from SqPlus::SQClassDef<TClassType>& SqPlus::SQClassDef<TClassType>::func(Func) [with Func = const String& (Base::*)(const String&)const, TClassType = Base] scriptbindings.cc:84: instantiated from here scriptbindings.cc:44: error: no matching function for call to Push(const String&) scriptbindings.cc:27: note: candidates are: void SqPlus::Push(bool) scriptbindings.cc:30: note: void SqPlus::Push(int) -- It compiles when - I remove the SqPlus namespace - move the Push(bool) and Push(int) down to the definition of Push(String) - move the Push(String) up to the Push(bool) and Push(int) The code is here (downsized from 80K+ lines and 2+ MB :-) ) class String { public: String(); }; class Base { public: Base(); const String& GetString(const String& key) const; bool GetBool() const; }; namespace SqPlus { template<class T> struct TypeWrapper { }; template<typename T> T * GetInstance() { return (T *)0; } inline void Push(bool value) { } inline bool Get(TypeWrapper<bool>) { return *GetInstance<bool>(); } inline void Push(int value) { } template<class RT> struct ReturnSpecialization { template <typename Callee> static void Call(Callee & callee,RT (Callee::*func)() const) { RT ret = (callee.*func)(); Push(ret); } template <typename Callee,typename P1> static void Call(Callee & callee,RT (Callee::*func)(P1) const) { RT ret = (callee.*func)(Get(TypeWrapper<P1>())); Push(ret); } }; template<typename Callee,typename RT> void Call(Callee & callee, RT (Callee::*func)() const) { ReturnSpecialization<RT>::Call(callee,func); } template<typename Callee,typename RT,typename P1> void Call(Callee & callee,RT (Callee::*func)(P1) const) { ReturnSpecialization<RT>::Call(callee,func); } template<typename Callee,typename Func> inline void RegisterInstance(Callee & callee,Func func) { Call(*(Callee *)0,*(Func *)0); } template<typename TClassType> struct SQClassDef { SQClassDef(); template<typename Func> SQClassDef & func(Func pfunc) { RegisterInstance(*(TClassType *)0,pfunc); return *this; } }; inline void Push(const String & value) { } inline const String & Get(TypeWrapper<const String &>) { return *GetInstance<String>(); } inline void Push(Base * value) { } inline Base & Get(TypeWrapper<Base &>) { return *GetInstance<Base>(); } }; void RegisterBindings() { SqPlus::SQClassDef<Base>(). func(&Base::GetString). func(&Base::GetBool); } References: http://forums.codeblocks.org/index.php?topic=3766.0 http://forums.codeblocks.org/index.php?topic=3481.0 http://squirrel-lang.org/forums/thread/1015.aspx -- Summary: no candidate even when it exists, depends on position of the function Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dan at danny dot cz http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28631