<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Can't initialize a function pointer with template parameter using C++-style initialization and a cast"
href="http://llvm.org/bugs/show_bug.cgi?id=17015">17015</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Can't initialize a function pointer with template parameter using C++-style initialization and a cast
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>abbeyj@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=11105" name="attach_11105" title="Test case">attachment 11105</a> <a href="attachment.cgi?id=11105&action=edit" title="Test case">[details]</a></span>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>