[LLVMbugs] [Bug 21055] New: "std::function<void()> foo = std::bind(std::exit, 0)" does not compile
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Sep 24 05:00:51 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=21055
Bug ID: 21055
Summary: "std::function<void()> foo = std::bind(std::exit, 0)"
does not compile
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: sami.liedes at iki.fi
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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.
------------------------------------------------------------
--
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/20140924/42303e41/attachment.html>
More information about the llvm-bugs
mailing list