[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


            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:
error: function cannot return function type '__func_type' (aka 'void (int)
      typedef _Bind<__func_type(typename decay<_BoundArgs>::type...)> type;
note: in instantiation of template class 'std::_Bind_helper<false, void
      __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);
note: candidate template ignored: couldn't infer template argument '_Result'
    bind(_Func&& __f, _BoundArgs&&... __args)
note: candidate template ignored: substitution failure [with _Func = void
      __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