<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 --- - "std::function<void()> foo = std::bind(std::exit, 0)" does not compile"
href="http://llvm.org/bugs/show_bug.cgi?id=21055">21055</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>"std::function<void()> foo = std::bind(std::exit, 0)" does not compile
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>sami.liedes@iki.fi
</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>As far as I can tell, this code is valid C++11:
------------------------------------------------------------
#include <functional>
#include <cstdlib>
int main() {
std::function<void()> foo = std::bind(std::exit, 0);
}
------------------------------------------------------------
However it does not compile:
------------------------------------------------------------
$ clang++ -c -Wall -std=c++11 bind.cpp
In file included from bind.cpp:1:
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/functional:1606:21:
error: function cannot return function type '__func_type' (aka 'void (int)
__attribute__((noreturn))')
typedef _Bind<__func_type(typename decay<_BoundArgs>::type...)> type;
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/functional:1622:5:
note: in instantiation of template class 'std::_Bind_helper<false, void
(&)(int)
__attribute__((noreturn)), int>' requested here
_Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
^
bind.cpp:16:33: note: while substituting deduced template arguments into
function template 'bind' [with _Func = void (&)(int) __attribute__((noreturn)),
_BoundArgs = <int>]
std::function<void()> bar = std::bind(std::exit, 0);
^
bind.cpp:16:33: error: no matching function for call to 'bind'
std::function<void()> bar = std::bind(std::exit, 0);
^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/functional:1650:5:
note: candidate template ignored: couldn't infer template argument '_Result'
bind(_Func&& __f, _BoundArgs&&... __args)
^
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/functional:1623:5:
note: candidate template ignored: substitution failure [with _Func = void
(&)(int)
__attribute__((noreturn)), _BoundArgs = <int>]
bind(_Func&& __f, _BoundArgs&&... __args)
^
2 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>