[LLVMbugs] [Bug 23141] New: std::bind const-qualifying bound arguments captured by value when compiled as C++14

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 6 22:07:11 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23141

            Bug ID: 23141
           Summary: std::bind const-qualifying bound arguments captured by
                    value when compiled as C++14
           Product: libc++
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eniebler at boost.org
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

The following code fails to compile when compiled as C++14:

#include <functional>
#include <type_traits>

struct Fun
{
  template<typename T, typename U>
  void operator()(T && t, U && u) const
  {
    static_assert(std::is_same<U, int &>::value, "");
  }
};

int main()
{
    std::bind(Fun{}, std::placeholders::_1, 42)("hello");
}

The error is:

    static_assert(std::is_same<U, int &>::value, "");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/clang-trunk/bin/../include/c++/v1/__functional_base:415:12: note: in
instantiation of function template specialization
      'Fun::operator()<char const (&)[6], const int &>' requested here
    return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
           ^
/usr/local/clang-trunk/bin/../include/c++/v1/__config:381:15: note: expanded
from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
1 error generated.


When compiled as C++11, the code compiles successfully.

-- 
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/20150407/452c2aac/attachment.html>


More information about the llvm-bugs mailing list