Community
Participate
Working Groups
Using 8.0 class Foo; template<typename Arg> class Callback { public: Callback(void (Foo::*function)(Arg arg)) { } }; typedef Callback<int> MyCallback; void Subscribe(MyCallback callback) { } class Foo { public: void Method(int) {} void Method() const {} }; int main() { Subscribe(MyCallback(&Foo::Method)); // Invalid overload of 'Foo::Method' return 0; } If I remove the typedef and replace MyCallback with Callback<int>, it works. If I declare a MyCallback outside the Subscribe call, it works.
Thanks, I can reproduce the issue.
Added testcase + fix.
This fix may have broken the fix for 241717.
The current solution is inconsisent: When the type id of an explicit type conversion in functional notation is a named type, then it is modelled as a function call. This is wrong but convenient. Otherwise we'd have to create an ambiguity node for every function call. In case the type-id is a class-type, the name is resolved to a constructor. When it is a cv-qualified class-type, then it is not. Also, in case the typedef is resolved to the constructor we loose information that is valuable for refactoring (see bug 241717). --> Let's not resolve the type-id to a constructor, rather than that genereate an implicit name for it. * We fail to compute the correct expression type: struct S {}; void test() { func(const S (3) As Doug figured out, the name is resolved to the constructor, therefore we loose the information about the typedef that is used to name the class-type. ==> To solve the issue we probably have to resolve the name to the typedef (or class-type in other cases). For the constructor we'd have to introduce an implicit name.
*** cdt git genie on behalf of Markus Schorn *** Bug 350345: Resolving explicit type conversions [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=645d8be5c61150069897447aafdf1a611e9c4e9a
Different fix in 8.0.2.