http://llvm.org/bugs/show_bug.cgi?id=7401

           Summary: Unhelpful error message when taking address of static
                    template function through an instance
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


bash-3.2$ cat test.cc
struct CallbackGenerator {
    template<typename T> static void Callback(int*);
};
void Foo() {
    void (*destruct)(int*);
    destruct = &CallbackGenerator().Callback<void>;
}
bash-3.2$ g++ -fsyntax-only test.cc && ./clang++ -fsyntax-only test.cc
test.cc:6:14: error: assigning to 'void (*)(int *)' from incompatible type
'<overloaded function type> *'
    destruct = &CallbackGenerator().Callback<void>;
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.


But, if I remove the template or take the address through the class, the error
goes away:


bash-3.2$ cat test.cc
struct CallbackGenerator {
    static void Callback(int*);
};
void Foo() {
    void (*destruct)(int*);
    destruct = &CallbackGenerator().Callback;
}
bash-3.2$ g++ -fsyntax-only test.cc && ./clang++ -fsyntax-only test.cc
bash-3.2$ cat test.cc
struct CallbackGenerator {
    template<typename T> static void Callback(int*);
};
void Foo() {
    void (*destruct)(int*);
    destruct = &CallbackGenerator::Callback<void>;
}
bash-3.2$ g++ -fsyntax-only test.cc && ./clang++ -fsyntax-only test.cc
bash-3.2$ 


I'm not sure which combinations of these are standard-compliant.

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to