<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 --- - Unhelpful error message when attempting to deduce an initializer list in a template context"
href="http://llvm.org/bugs/show_bug.cgi?id=18740">18740</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unhelpful error message when attempting to deduce an initializer list in a template context
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>matthew.chaplain@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>I have the following code:
-----
#include <vector>
#define RETURNS(...) -> decltype((__VA_ARGS__)) { return (__VA_ARGS__); }
template <typename This, typename... Args>
auto fun(This &&this_, Args&&... args)
RETURNS(this_.fun(std::forward<Args>(args)...))
struct X
{
void fun(std::vector<int> v) {}
};
int main()
{
X x;
fun(x, {1, 2, 3});
}
-----
When compiling, this yields the following errors:
-----
subst.cpp:16:5: error: no matching function for call to 'fun'
fun(x, {1, 2, 3});
^~~
subst.cpp:6:6: note: candidate template ignored: substitution failure [with
This
= X &, Args = <>]: too few arguments to function call, single argument
'v'
was not specified
auto fun(This &&this_, Args&&... args)
RETURNS(this_.fun(std::forward<Args>(args)...))
^
~
1 error generated.
-----
As I understand (from the discussion in
<a href="http://stackoverflow.com/questions/21573808/using-initializer-lists-with-variadic-templates">http://stackoverflow.com/questions/21573808/using-initializer-lists-with-variadic-templates</a>),
the initializer list could not be deduced. This is not clear in the message,
however, especially with the (IMO) misleading "Args = <>".
Note: reversing the order of declaration of fun<> and struct X instead yields
the following equally misleading error message (because yes it was, right
there!)
-----
subst.cpp:17:5: error: no matching function for call to 'fun'
fun(x, {1, 2, 3});
^~~
subst.cpp:12:6: note: candidate template ignored: substitution failure [with
This = X &, Args = <>]: too few arguments to function call, single
argument 'v' was not specified
auto fun(This &&this_, Args&&... args)
RETURNS(this_.fun(std::forward<Args>(args)...))
^
~
1 error 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>