[LLVMbugs] [Bug 17015] New: Can't initialize a function pointer with template parameter using C++-style initialization and a cast
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Aug 27 15:40:30 PDT 2013
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: unassignedclangbugs at nondot.org
Reporter: abbeyj at gmail.com
CC: llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130827/77a3730e/attachment.html>
More information about the llvm-bugs
mailing list