<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 --- - In-class initialization with template function call fails to compile"
href="http://llvm.org/bugs/show_bug.cgi?id=21755">21755</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>In-class initialization with template function call fails to compile
</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>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>groszdanireg@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>template<typename T, typename U> int f()
{
return 42;
}
struct C
{
int v=f<int,int>();
};
int main() { return 0; }
This fails to compile:
$ clang -std=c++11 inclass_init_template.cpp
inclass_init_template.cpp:8:15: error: expected member name or ';' after
declaration specifiers
int v=f<int,int>();
~~~ ^
inclass_init_template.cpp:8:15: error: expected ';' at end of declaration list
int v=f<int,int>();
^
;
inclass_init_template.cpp:8:14: error: expected '>'
int v=f<int,int>();
^
3 errors generated.
It compiles
- if there is one template parameter,
- or if the initialization is placed in the initializer list of a constructor
- or if the same declaration is used to declare a local variable
- or if the function is made to have parameters and its template arguments are
deduced from the parameters,
- or if GCC 4.8.3 is used instead of clang.</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>