[LLVMbugs] [Bug 7401] New: Unhelpful error message when taking address of static template function through an instance

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 17 14:39:48 PDT 2010


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: unassignedclangbugs at nondot.org
        ReportedBy: jyasskin at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


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.



More information about the llvm-bugs mailing list