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

            Bug ID: 17015
           Summary: Can't initialize a function pointer with template
                    parameter using C++-style initialization and a cast
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 11105
  --> http://llvm.org/bugs/attachment.cgi?id=11105&action=edit
Test case

The following test case (also attached) is rejected by clang but accepted by
gcc, MSVC and the VMS C++ compiler.

template <typename T>
class D {};

void foo(int, D<int>&)
{
}

void bar()
{
    void (*pfoo1)(int, D<int>&) = (void (*)(int, D<int>&))foo;    // ok
    void (*pfoo2)(int, D<int>&) ( (void (*)(int, D<int>&))foo );  // error
}


Output from attempting to compile:
fptr.cpp:11:47: error: expected parameter declarator
        void (*pfoo2)(int, D<int>&) ( (void (*)(int, D<int>&))foo );  // error
                                                     ^
fptr.cpp:11:53: error: expected ')'
        void (*pfoo2)(int, D<int>&) ( (void (*)(int, D<int>&))foo );  // error
                                                           ^
fptr.cpp:11:41: note: to match this '('
        void (*pfoo2)(int, D<int>&) ( (void (*)(int, D<int>&))foo );  // error
                                               ^
fptr.cpp:11:9: error: cannot initialize a variable of type 'void (*)(int,
D<int> &)' with an rvalue of type 'void (*)(int)': different number of
parameters (2 vs 1)
        void (*pfoo2)(int, D<int>&) ( (void (*)(int, D<int>&))foo );  // error
               ^                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.

-- 
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